var __decorate=this&&this.__decorate||function(e,t,i,r){var n,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,i,r);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,i,s):n(t,i))||s);return o>3&&s&&Object.defineProperty(t,i,s),s},__extends=this&&this.__extends||(function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])};return function(t,i){function r(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}})(),BABYLON;!(function(e){var t=(function(){function e(){}return Object.defineProperty(e,"KEYDOWN",{get:function(){return e._KEYDOWN},enumerable:!0,configurable:!0}),Object.defineProperty(e,"KEYUP",{get:function(){return e._KEYUP},enumerable:!0,configurable:!0}),e._KEYDOWN=1,e._KEYUP=2,e})();e.KeyboardEventTypes=t;var i=(function(){function e(e,t){this.type=e,this.event=t}return e})();e.KeyboardInfo=i;var r=(function(e){function t(t,i){var r=e.call(this,t,i)||this;return r.skipOnPointerObservable=!1,r}return __extends(t,e),t})(i);e.KeyboardInfoPre=r})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){}return Object.defineProperty(e,"POINTERDOWN",{get:function(){return e._POINTERDOWN},enumerable:!0,configurable:!0}),Object.defineProperty(e,"POINTERUP",{get:function(){return e._POINTERUP},enumerable:!0,configurable:!0}),Object.defineProperty(e,"POINTERMOVE",{get:function(){return e._POINTERMOVE},enumerable:!0,configurable:!0}),Object.defineProperty(e,"POINTERWHEEL",{get:function(){return e._POINTERWHEEL},enumerable:!0,configurable:!0}),Object.defineProperty(e,"POINTERPICK",{get:function(){return e._POINTERPICK},enumerable:!0,configurable:!0}),Object.defineProperty(e,"POINTERTAP",{get:function(){return e._POINTERTAP},enumerable:!0,configurable:!0}),Object.defineProperty(e,"POINTERDOUBLETAP",{get:function(){return e._POINTERDOUBLETAP},enumerable:!0,configurable:!0}),e._POINTERDOWN=1,e._POINTERUP=2,e._POINTERMOVE=4,e._POINTERWHEEL=8,e._POINTERPICK=16,e._POINTERTAP=32,e._POINTERDOUBLETAP=64,e})();e.PointerEventTypes=t;var i=(function(){function e(e,t){this.type=e,this.event=t}return e})();e.PointerInfoBase=i;var r=(function(t){function i(i,r,n,o){var s=t.call(this,i,r)||this;return s.skipOnPointerObservable=!1,s.localPosition=new e.Vector2(n,o),s}return __extends(i,t),i})(i);e.PointerInfoPre=r;var n=(function(e){function t(t,i,r){var n=e.call(this,t,i)||this;return n.pickInfo=r,n}return __extends(t,e),t})(i);e.PointerInfo=n})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){e.ToGammaSpace=1/2.2,e.ToLinearSpace=2.2,e.Epsilon=.001;var t=(function(){function t(e,t,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),this.r=e,this.g=t,this.b=i}return t.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+"}"},t.prototype.getClassName=function(){return"Color3"},t.prototype.getHashCode=function(){var e=this.r||0;return e=397*e^(this.g||0),e=397*e^(this.b||0)},t.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,this},t.prototype.toColor4=function(e){return void 0===e&&(e=1),new i(this.r,this.g,this.b,e)},t.prototype.asArray=function(){var e=new Array;return this.toArray(e,0),e},t.prototype.toLuminance=function(){return.3*this.r+.59*this.g+.11*this.b},t.prototype.multiply=function(e){return new t(this.r*e.r,this.g*e.g,this.b*e.b)},t.prototype.multiplyToRef=function(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,this},t.prototype.equals=function(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b},t.prototype.equalsFloats=function(e,t,i){return this.r===e&&this.g===t&&this.b===i},t.prototype.scale=function(e){return new t(this.r*e,this.g*e,this.b*e)},t.prototype.scaleToRef=function(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,this},t.prototype.add=function(e){return new t(this.r+e.r,this.g+e.g,this.b+e.b)},t.prototype.addToRef=function(e,t){return t.r=this.r+e.r,t.g=this.g+e.g,t.b=this.b+e.b,this},t.prototype.subtract=function(e){return new t(this.r-e.r,this.g-e.g,this.b-e.b)},t.prototype.subtractToRef=function(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,this},t.prototype.clone=function(){return new t(this.r,this.g,this.b)},t.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},t.prototype.copyFromFloats=function(e,t,i){return this.r=e,this.g=t,this.b=i,this},t.prototype.set=function(e,t,i){return this.copyFromFloats(e,t,i)},t.prototype.toHexString=function(){var t=255*this.r|0,i=255*this.g|0,r=255*this.b|0;return"#"+e.Scalar.ToHex(t)+e.Scalar.ToHex(i)+e.Scalar.ToHex(r)},t.prototype.toLinearSpace=function(){var e=new t;return this.toLinearSpaceToRef(e),e},t.prototype.toLinearSpaceToRef=function(t){return t.r=Math.pow(this.r,e.ToLinearSpace),t.g=Math.pow(this.g,e.ToLinearSpace),t.b=Math.pow(this.b,e.ToLinearSpace),this},t.prototype.toGammaSpace=function(){var e=new t;return this.toGammaSpaceToRef(e),e},t.prototype.toGammaSpaceToRef=function(t){return t.r=Math.pow(this.r,e.ToGammaSpace),t.g=Math.pow(this.g,e.ToGammaSpace),t.b=Math.pow(this.b,e.ToGammaSpace),this},t.FromHexString=function(e){if("#"!==e.substring(0,1)||7!==e.length)return new t(0,0,0);var i=parseInt(e.substring(1,3),16),r=parseInt(e.substring(3,5),16),n=parseInt(e.substring(5,7),16);return t.FromInts(i,r,n)},t.FromArray=function(e,i){return void 0===i&&(i=0),new t(e[i],e[i+1],e[i+2])},t.FromInts=function(e,i,r){return new t(e/255,i/255,r/255)},t.Lerp=function(e,i,r){return new t(e.r+(i.r-e.r)*r,e.g+(i.g-e.g)*r,e.b+(i.b-e.b)*r)},t.Red=function(){return new t(1,0,0)},t.Green=function(){return new t(0,1,0)},t.Blue=function(){return new t(0,0,1)},t.Black=function(){return new t(0,0,0)},t.White=function(){return new t(1,1,1)},t.Purple=function(){return new t(.5,0,.5)},t.Magenta=function(){return new t(1,0,1)},t.Yellow=function(){return new t(1,1,0)},t.Gray=function(){return new t(.5,.5,.5)},t.Teal=function(){return new t(0,1,1)},t.Random=function(){return new t(Math.random(),Math.random(),Math.random())},t})();e.Color3=t;var i=(function(){function t(e,t,i,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=1),this.r=e,this.g=t,this.b=i,this.a=r}return t.prototype.addInPlace=function(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this.a+=e.a,this},t.prototype.asArray=function(){var e=new Array;return this.toArray(e,0),e},t.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e[t+3]=this.a,this},t.prototype.add=function(e){return new t(this.r+e.r,this.g+e.g,this.b+e.b,this.a+e.a)},t.prototype.subtract=function(e){return new t(this.r-e.r,this.g-e.g,this.b-e.b,this.a-e.a)},t.prototype.subtractToRef=function(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,t.a=this.a-e.a,this},t.prototype.scale=function(e){return new t(this.r*e,this.g*e,this.b*e,this.a*e)},t.prototype.scaleToRef=function(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,t.a=this.a*e,this},t.prototype.multiply=function(e){return new t(this.r*e.r,this.g*e.g,this.b*e.b,this.a*e.a)},t.prototype.multiplyToRef=function(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,t.a=this.a*e.a,t},t.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+" A:"+this.a+"}"},t.prototype.getClassName=function(){return"Color4"},t.prototype.getHashCode=function(){var e=this.r||0;return e=397*e^(this.g||0),e=397*e^(this.b||0),e=397*e^(this.a||0)},t.prototype.clone=function(){return new t(this.r,this.g,this.b,this.a)},t.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this},t.prototype.copyFromFloats=function(e,t,i,r){return this.r=e,this.g=t,this.b=i,this.a=r,this},t.prototype.set=function(e,t,i,r){return this.copyFromFloats(e,t,i,r)},t.prototype.toHexString=function(){var t=255*this.r|0,i=255*this.g|0,r=255*this.b|0,n=255*this.a|0;return"#"+e.Scalar.ToHex(t)+e.Scalar.ToHex(i)+e.Scalar.ToHex(r)+e.Scalar.ToHex(n)},t.prototype.toLinearSpace=function(){var e=new t;return this.toLinearSpaceToRef(e),e},t.prototype.toLinearSpaceToRef=function(t){return t.r=Math.pow(this.r,e.ToLinearSpace),t.g=Math.pow(this.g,e.ToLinearSpace),t.b=Math.pow(this.b,e.ToLinearSpace),t.a=this.a,this},t.prototype.toGammaSpace=function(){var e=new t;return this.toGammaSpaceToRef(e),e},t.prototype.toGammaSpaceToRef=function(t){return t.r=Math.pow(this.r,e.ToGammaSpace),t.g=Math.pow(this.g,e.ToGammaSpace),t.b=Math.pow(this.b,e.ToGammaSpace),t.a=this.a,this},t.FromHexString=function(e){if("#"!==e.substring(0,1)||9!==e.length)return new t(0,0,0,0);var i=parseInt(e.substring(1,3),16),r=parseInt(e.substring(3,5),16),n=parseInt(e.substring(5,7),16),o=parseInt(e.substring(7,9),16);return t.FromInts(i,r,n,o)},t.Lerp=function(e,i,r){var n=new t(0,0,0,0);return t.LerpToRef(e,i,r,n),n},t.LerpToRef=function(e,t,i,r){r.r=e.r+(t.r-e.r)*i,r.g=e.g+(t.g-e.g)*i,r.b=e.b+(t.b-e.b)*i,r.a=e.a+(t.a-e.a)*i},t.FromArray=function(e,i){return void 0===i&&(i=0),new t(e[i],e[i+1],e[i+2],e[i+3])},t.FromInts=function(e,i,r,n){return new t(e/255,i/255,r/255,n/255)},t.CheckColors4=function(e,t){if(e.length===3*t){for(var i=[],r=0;rr.x?r.x:n,n=nr.y?r.y:o,o=oi.x?e.x:i.x,e.y>i.y?e.y:i.y)},t.Transform=function(e,i){var r=t.Zero();return t.TransformToRef(e,i,r),r},t.TransformToRef=function(e,t,i){var r=e.x*t.m[0]+e.y*t.m[4]+t.m[12],n=e.x*t.m[1]+e.y*t.m[5]+t.m[13];i.x=r,i.y=n},t.PointInTriangle=function(e,t,i,r){var n=.5*(-i.y*r.x+t.y*(-i.x+r.x)+t.x*(i.y-r.y)+i.x*r.y),o=n<0?-1:1,s=(t.y*r.x-t.x*r.y+(r.y-t.y)*e.x+(t.x-r.x)*e.y)*o,a=(t.x*i.y-t.y*i.x+(t.y-i.y)*e.x+(i.x-t.x)*e.y)*o;return s>0&&a>0&&s+a<2*n*o},t.Distance=function(e,i){return Math.sqrt(t.DistanceSquared(e,i))},t.DistanceSquared=function(e,t){var i=e.x-t.x,r=e.y-t.y;return i*i+r*r},t.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},t.DistanceOfPointFromSegment=function(e,i,r){var n=t.DistanceSquared(i,r);if(0===n)return t.Distance(e,i);var o=r.subtract(i),s=Math.max(0,Math.min(1,t.Dot(e.subtract(i),o)/n)),a=i.add(o.multiplyByFloats(s,s));return t.Distance(e,a)},t})();e.Vector2=r;var n=(function(){function t(e,t,i){this.x=e,this.y=t,this.z=i}return t.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+"}"},t.prototype.getClassName=function(){return"Vector3"},t.prototype.getHashCode=function(){var e=this.x||0;return e=397*e^(this.y||0),e=397*e^(this.z||0)},t.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},t.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,this},t.prototype.toQuaternion=function(){var e=new a(0,0,0,1),t=Math.cos(.5*(this.x+this.z)),i=Math.sin(.5*(this.x+this.z)),r=Math.cos(.5*(this.z-this.x)),n=Math.sin(.5*(this.z-this.x)),o=Math.cos(.5*this.y),s=Math.sin(.5*this.y);return e.x=r*s,e.y=-n*s,e.z=i*o,e.w=t*o,e},t.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this},t.prototype.add=function(e){return new t(this.x+e.x,this.y+e.y,this.z+e.z)},t.prototype.addToRef=function(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,t.z=this.z+e.z,this},t.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this},t.prototype.subtract=function(e){return new t(this.x-e.x,this.y-e.y,this.z-e.z)},t.prototype.subtractToRef=function(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,t.z=this.z-e.z,this},t.prototype.subtractFromFloats=function(e,i,r){return new t(this.x-e,this.y-i,this.z-r)},t.prototype.subtractFromFloatsToRef=function(e,t,i,r){return r.x=this.x-e,r.y=this.y-t,r.z=this.z-i,this},t.prototype.negate=function(){return new t(-this.x,-this.y,-this.z)},t.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this},t.prototype.scale=function(e){return new t(this.x*e,this.y*e,this.z*e)},t.prototype.scaleToRef=function(e,t){return t.x=this.x*e,t.y=this.y*e,t.z=this.z*e,this},t.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z},t.prototype.equalsWithEpsilon=function(t,i){return void 0===i&&(i=e.Epsilon),t&&e.Scalar.WithinEpsilon(this.x,t.x,i)&&e.Scalar.WithinEpsilon(this.y,t.y,i)&&e.Scalar.WithinEpsilon(this.z,t.z,i)},t.prototype.equalsToFloats=function(e,t,i){return this.x===e&&this.y===t&&this.z===i},t.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this},t.prototype.multiply=function(e){return new t(this.x*e.x,this.y*e.y,this.z*e.z)},t.prototype.multiplyToRef=function(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,t.z=this.z*e.z,this},t.prototype.multiplyByFloats=function(e,i,r){return new t(this.x*e,this.y*i,this.z*r)},t.prototype.divide=function(e){return new t(this.x/e.x,this.y/e.y,this.z/e.z)},t.prototype.divideToRef=function(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,t.z=this.z/e.z,this},t.prototype.MinimizeInPlace=function(e){return e.xthis.x&&(this.x=e.x),e.y>this.y&&(this.y=e.y),e.z>this.z&&(this.z=e.z),this},Object.defineProperty(t.prototype,"isNonUniform",{get:function(){var e=Math.abs(this.x),t=Math.abs(this.y);if(e!==t)return!0;var i=Math.abs(this.z);return e!==i||t!==i},enumerable:!0,configurable:!0}),t.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},t.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z},t.prototype.normalize=function(){var e=this.length();if(0===e||1===e)return this;var t=1/e;return this.x*=t,this.y*=t,this.z*=t,this},t.prototype.clone=function(){return new t(this.x,this.y,this.z)},t.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},t.prototype.copyFromFloats=function(e,t,i){return this.x=e,this.y=t,this.z=i,this},t.prototype.set=function(e,t,i){return this.copyFromFloats(e,t,i)},t.GetClipFactor=function(e,i,r,n){var o=t.Dot(e,r)-n;return o/(o-(t.Dot(i,r)-n))},t.FromArray=function(e,i){return i||(i=0),new t(e[i],e[i+1],e[i+2])},t.FromFloatArray=function(e,i){return t.FromArray(e,i)},t.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2]},t.FromFloatArrayToRef=function(e,i,r){return t.FromArrayToRef(e,i,r)},t.FromFloatsToRef=function(e,t,i,r){r.x=e,r.y=t,r.z=i},t.Zero=function(){return new t(0,0,0)},t.One=function(){return new t(1,1,1)},t.Up=function(){return new t(0,1,0)},t.Forward=function(){return new t(0,0,1)},t.Right=function(){return new t(1,0,0)},t.Left=function(){return new t(-1,0,0)},t.TransformCoordinates=function(e,i){var r=t.Zero();return t.TransformCoordinatesToRef(e,i,r),r},t.TransformCoordinatesToRef=function(e,t,i){var r=e.x*t.m[0]+e.y*t.m[4]+e.z*t.m[8]+t.m[12],n=e.x*t.m[1]+e.y*t.m[5]+e.z*t.m[9]+t.m[13],o=e.x*t.m[2]+e.y*t.m[6]+e.z*t.m[10]+t.m[14],s=e.x*t.m[3]+e.y*t.m[7]+e.z*t.m[11]+t.m[15];i.x=r/s,i.y=n/s,i.z=o/s},t.TransformCoordinatesFromFloatsToRef=function(e,t,i,r,n){var o=e*r.m[0]+t*r.m[4]+i*r.m[8]+r.m[12],s=e*r.m[1]+t*r.m[5]+i*r.m[9]+r.m[13],a=e*r.m[2]+t*r.m[6]+i*r.m[10]+r.m[14],l=e*r.m[3]+t*r.m[7]+i*r.m[11]+r.m[15];n.x=o/l,n.y=s/l,n.z=a/l},t.TransformNormal=function(e,i){var r=t.Zero();return t.TransformNormalToRef(e,i,r),r},t.TransformNormalToRef=function(e,t,i){var r=e.x*t.m[0]+e.y*t.m[4]+e.z*t.m[8],n=e.x*t.m[1]+e.y*t.m[5]+e.z*t.m[9],o=e.x*t.m[2]+e.y*t.m[6]+e.z*t.m[10];i.x=r,i.y=n,i.z=o},t.TransformNormalFromFloatsToRef=function(e,t,i,r,n){n.x=e*r.m[0]+t*r.m[4]+i*r.m[8],n.y=e*r.m[1]+t*r.m[5]+i*r.m[9],n.z=e*r.m[2]+t*r.m[6]+i*r.m[10]},t.CatmullRom=function(e,i,r,n,o){var s=o*o,a=o*s;return new t(.5*(2*i.x+(-e.x+r.x)*o+(2*e.x-5*i.x+4*r.x-n.x)*s+(-e.x+3*i.x-3*r.x+n.x)*a),.5*(2*i.y+(-e.y+r.y)*o+(2*e.y-5*i.y+4*r.y-n.y)*s+(-e.y+3*i.y-3*r.y+n.y)*a),.5*(2*i.z+(-e.z+r.z)*o+(2*e.z-5*i.z+4*r.z-n.z)*s+(-e.z+3*i.z-3*r.z+n.z)*a))},t.Clamp=function(e,i,r){var n=e.x;n=n>r.x?r.x:n,n=nr.y?r.y:o,o=or.z?r.z:s,s=sthis.x&&(this.x=e.x),e.y>this.y&&(this.y=e.y),e.z>this.z&&(this.z=e.z),e.w>this.w&&(this.w=e.w),this},t.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},t.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},t.prototype.normalize=function(){var e=this.length();if(0===e)return this;var t=1/e;return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},t.prototype.toVector3=function(){return new n(this.x,this.y,this.z)},t.prototype.clone=function(){return new t(this.x,this.y,this.z,this.w)},t.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},t.prototype.copyFromFloats=function(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this},t.prototype.set=function(e,t,i,r){return this.copyFromFloats(e,t,i,r)},t.FromArray=function(e,i){return i||(i=0),new t(e[i],e[i+1],e[i+2],e[i+3])},t.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2],i.w=e[t+3]},t.FromFloatArrayToRef=function(e,i,r){t.FromArrayToRef(e,i,r)},t.FromFloatsToRef=function(e,t,i,r,n){n.x=e,n.y=t,n.z=i,n.w=r},t.Zero=function(){return new t(0,0,0,0)},t.One=function(){return new t(1,1,1,1)},t.Normalize=function(e){var i=t.Zero();return t.NormalizeToRef(e,i),i},t.NormalizeToRef=function(e,t){t.copyFrom(e),t.normalize()},t.Minimize=function(e,t){var i=e.clone();return i.MinimizeInPlace(t),i},t.Maximize=function(e,t){var i=e.clone();return i.MaximizeInPlace(t),i},t.Distance=function(e,i){return Math.sqrt(t.DistanceSquared(e,i))},t.DistanceSquared=function(e,t){var i=e.x-t.x,r=e.y-t.y,n=e.z-t.z,o=e.w-t.w;return i*i+r*r+n*n+o*o},t.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},t.TransformNormal=function(e,i){var r=t.Zero();return t.TransformNormalToRef(e,i,r),r},t.TransformNormalToRef=function(e,t,i){var r=e.x*t.m[0]+e.y*t.m[4]+e.z*t.m[8],n=e.x*t.m[1]+e.y*t.m[5]+e.z*t.m[9],o=e.x*t.m[2]+e.y*t.m[6]+e.z*t.m[10];i.x=r,i.y=n,i.z=o,i.w=e.w},t.TransformNormalFromFloatsToRef=function(e,t,i,r,n,o){o.x=e*n.m[0]+t*n.m[4]+i*n.m[8],o.y=e*n.m[1]+t*n.m[5]+i*n.m[9],o.z=e*n.m[2]+t*n.m[6]+i*n.m[10],o.w=r},t})();e.Vector4=o;var s=(function(){function e(e,t){this.width=e,this.height=t}return e.prototype.toString=function(){return"{W: "+this.width+", H: "+this.height+"}"},e.prototype.getClassName=function(){return"Size"},e.prototype.getHashCode=function(){var e=this.width||0;return e=397*e^(this.height||0)},e.prototype.copyFrom=function(e){this.width=e.width,this.height=e.height},e.prototype.copyFromFloats=function(e,t){return this.width=e,this.height=t,this},e.prototype.set=function(e,t){return this.copyFromFloats(e,t)},e.prototype.multiplyByFloats=function(t,i){return new e(this.width*t,this.height*i)},e.prototype.clone=function(){return new e(this.width,this.height)},e.prototype.equals=function(e){return!!e&&(this.width===e.width&&this.height===e.height)},Object.defineProperty(e.prototype,"surface",{get:function(){return this.width*this.height},enumerable:!0,configurable:!0}),e.Zero=function(){return new e(0,0)},e.prototype.add=function(t){return new e(this.width+t.width,this.height+t.height)},e.prototype.subtract=function(t){return new e(this.width-t.width,this.height-t.height)},e.Lerp=function(t,i,r){return new e(t.width+(i.width-t.width)*r,t.height+(i.height-t.height)*r)},e})();e.Size=s;var a=(function(){function t(e,t,i,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=1),this.x=e,this.y=t,this.z=i,this.w=r}return t.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+" W:"+this.w+"}"},t.prototype.getClassName=function(){return"Quaternion"},t.prototype.getHashCode=function(){var e=this.x||0;return e=397*e^(this.y||0),e=397*e^(this.z||0),e=397*e^(this.w||0)},t.prototype.asArray=function(){return[this.x,this.y,this.z,this.w]},t.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w},t.prototype.clone=function(){return new t(this.x,this.y,this.z,this.w)},t.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},t.prototype.copyFromFloats=function(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this},t.prototype.set=function(e,t,i,r){return this.copyFromFloats(e,t,i,r)},t.prototype.add=function(e){return new t(this.x+e.x,this.y+e.y,this.z+e.z,this.w+e.w)},t.prototype.subtract=function(e){return new t(this.x-e.x,this.y-e.y,this.z-e.z,this.w-e.w)},t.prototype.scale=function(e){return new t(this.x*e,this.y*e,this.z*e,this.w*e)},t.prototype.multiply=function(e){var i=new t(0,0,0,1);return this.multiplyToRef(e,i),i},t.prototype.multiplyToRef=function(e,t){var i=this.x*e.w+this.y*e.z-this.z*e.y+this.w*e.x,r=-this.x*e.z+this.y*e.w+this.z*e.x+this.w*e.y,n=this.x*e.y-this.y*e.x+this.z*e.w+this.w*e.z,o=-this.x*e.x-this.y*e.y-this.z*e.z+this.w*e.w;return t.copyFromFloats(i,r,n,o),this},t.prototype.multiplyInPlace=function(e){return this.multiplyToRef(e,this),this},t.prototype.conjugateToRef=function(e){return e.copyFromFloats(-this.x,-this.y,-this.z,this.w),this},t.prototype.conjugateInPlace=function(){return this.x*=-1,this.y*=-1,this.z*=-1,this},t.prototype.conjugate=function(){return new t(-this.x,-this.y,-this.z,this.w)},t.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},t.prototype.normalize=function(){var e=1/this.length();return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},t.prototype.toEulerAngles=function(e){void 0===e&&(e="YZX");var t=n.Zero();return this.toEulerAnglesToRef(t,e),t},t.prototype.toEulerAnglesToRef=function(e,t){void 0===t&&(t="YZX");var i=this.z,r=this.x,n=this.y,o=this.w,s=o*o,a=i*i,l=r*r,h=n*n,u=n*i-r*o;return u<-.4999999?(e.y=2*Math.atan2(n,o),e.x=Math.PI/2,e.z=0):u>.4999999?(e.y=2*Math.atan2(n,o),e.x=-Math.PI/2,e.z=0):(e.z=Math.atan2(2*(r*n+i*o),-a-l+h+s),e.x=Math.asin(-2*(i*n-r*o)),e.y=Math.atan2(2*(i*r+n*o),a-l-h+s)),this},t.prototype.toRotationMatrix=function(e){var t=this.x*this.x,i=this.y*this.y,r=this.z*this.z,n=this.x*this.y,o=this.z*this.w,s=this.z*this.x,a=this.y*this.w,l=this.y*this.z,h=this.x*this.w;return e.m[0]=1-2*(i+r),e.m[1]=2*(n+o),e.m[2]=2*(s-a),e.m[3]=0,e.m[4]=2*(n-o),e.m[5]=1-2*(r+t),e.m[6]=2*(l+h),e.m[7]=0,e.m[8]=2*(s+a),e.m[9]=2*(l-h),e.m[10]=1-2*(i+t),e.m[11]=0,e.m[12]=0,e.m[13]=0,e.m[14]=0,e.m[15]=1,e._markAsUpdated(),this},t.prototype.fromRotationMatrix=function(e){return t.FromRotationMatrixToRef(e,this),this},t.FromRotationMatrix=function(e){var i=new t;return t.FromRotationMatrixToRef(e,i),i},t.FromRotationMatrixToRef=function(e,t){var i,r=e.m,n=r[0],o=r[4],s=r[8],a=r[1],l=r[5],h=r[9],u=r[2],c=r[6],f=r[10],d=n+l+f;d>0?(i=.5/Math.sqrt(d+1),t.w=.25/i,t.x=(c-h)*i,t.y=(s-u)*i,t.z=(a-o)*i):n>l&&n>f?(i=2*Math.sqrt(1+n-l-f),t.w=(c-h)/i,t.x=.25*i,t.y=(o+a)/i,t.z=(s+u)/i):l>f?(i=2*Math.sqrt(1+l-n-f),t.w=(s-u)/i,t.x=(o+a)/i,t.y=.25*i,t.z=(h+c)/i):(i=2*Math.sqrt(1+f-n-l),t.w=(a-o)/i,t.x=(s+u)/i,t.y=(h+c)/i,t.z=.25*i)},t.Zero=function(){return new t(0,0,0,0)},t.Inverse=function(e){return new t(-e.x,-e.y,-e.z,e.w)},t.Identity=function(){return new t(0,0,0,1)},t.IsIdentity=function(e){return e&&0===e.x&&0===e.y&&0===e.z&&1===e.w},t.RotationAxis=function(e,i){return t.RotationAxisToRef(e,i,new t)},t.RotationAxisToRef=function(e,t,i){ var r=Math.sin(t/2);return e.normalize(),i.w=Math.cos(t/2),i.x=e.x*r,i.y=e.y*r,i.z=e.z*r,i},t.FromArray=function(e,i){return i||(i=0),new t(e[i],e[i+1],e[i+2],e[i+3])},t.RotationYawPitchRoll=function(e,i,r){var n=new t;return t.RotationYawPitchRollToRef(e,i,r,n),n},t.RotationYawPitchRollToRef=function(e,t,i,r){var n=.5*i,o=.5*t,s=.5*e,a=Math.sin(n),l=Math.cos(n),h=Math.sin(o),u=Math.cos(o),c=Math.sin(s),f=Math.cos(s);r.x=f*h*l+c*u*a,r.y=c*u*l-f*h*a,r.z=f*u*a-c*h*l,r.w=f*u*l+c*h*a},t.RotationAlphaBetaGamma=function(e,i,r){var n=new t;return t.RotationAlphaBetaGammaToRef(e,i,r,n),n},t.RotationAlphaBetaGammaToRef=function(e,t,i,r){var n=.5*(i+e),o=.5*(i-e),s=.5*t;r.x=Math.cos(o)*Math.sin(s),r.y=Math.sin(o)*Math.sin(s),r.z=Math.sin(n)*Math.cos(s),r.w=Math.cos(n)*Math.cos(s)},t.RotationQuaternionFromAxis=function(e,i,r,n){var o=new t(0,0,0,0);return t.RotationQuaternionFromAxisToRef(e,i,r,o),o},t.RotationQuaternionFromAxisToRef=function(t,i,r,n){var o=A.Matrix[0];e.Matrix.FromXYZAxesToRef(t.normalize(),i.normalize(),r.normalize(),o),e.Quaternion.FromRotationMatrixToRef(o,n)},t.Slerp=function(e,i,r){var n=t.Identity();return t.SlerpToRef(e,i,r,n),n},t.SlerpToRef=function(e,t,i,r){var n,o,s=i,a=e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w,l=!1;if(a<0&&(l=!0,a=-a),a>.999999)o=1-s,n=l?-s:s;else{var h=Math.acos(a),u=1/Math.sin(h);o=Math.sin((1-s)*h)*u,n=l?-Math.sin(s*h)*u:Math.sin(s*h)*u}r.x=o*e.x+n*t.x,r.y=o*e.y+n*t.y,r.z=o*e.z+n*t.z,r.w=o*e.w+n*t.w},t.Hermite=function(e,i,r,n,o){var s=o*o,a=o*s,l=2*a-3*s+1,h=-2*a+3*s,u=a-2*s+o,c=a-s;return new t(e.x*l+r.x*h+i.x*u+n.x*c,e.y*l+r.y*h+i.y*u+n.y*c,e.z*l+r.z*h+i.z*u+n.z*c,e.w*l+r.w*h+i.w*u+n.w*c)},t})();e.Quaternion=a;var l=(function(){function t(){this._isIdentity=!1,this._isIdentityDirty=!0,this.m=new Float32Array(16),this._markAsUpdated()}return t.prototype._markAsUpdated=function(){this.updateFlag=t._updateFlagSeed++,this._isIdentityDirty=!0},t.prototype.isIdentity=function(e){return void 0===e&&(e=!1),this._isIdentityDirty&&(this._isIdentityDirty=!1,1!==this.m[0]||1!==this.m[5]||1!==this.m[15]?this._isIdentity=!1:0!==this.m[1]||0!==this.m[2]||0!==this.m[3]||0!==this.m[4]||0!==this.m[6]||0!==this.m[7]||0!==this.m[8]||0!==this.m[9]||0!==this.m[11]||0!==this.m[12]||0!==this.m[13]||0!==this.m[14]?this._isIdentity=!1:this._isIdentity=!0,e||1===this.m[10]||(this._isIdentity=!1)),this._isIdentity},t.prototype.determinant=function(){var e=this.m[10]*this.m[15]-this.m[11]*this.m[14],t=this.m[9]*this.m[15]-this.m[11]*this.m[13],i=this.m[9]*this.m[14]-this.m[10]*this.m[13],r=this.m[8]*this.m[15]-this.m[11]*this.m[12],n=this.m[8]*this.m[14]-this.m[10]*this.m[12],o=this.m[8]*this.m[13]-this.m[9]*this.m[12];return this.m[0]*(this.m[5]*e-this.m[6]*t+this.m[7]*i)-this.m[1]*(this.m[4]*e-this.m[6]*r+this.m[7]*n)+this.m[2]*(this.m[4]*t-this.m[5]*r+this.m[7]*o)-this.m[3]*(this.m[4]*i-this.m[5]*n+this.m[6]*o)},t.prototype.toArray=function(){return this.m},t.prototype.asArray=function(){return this.toArray()},t.prototype.invert=function(){return this.invertToRef(this),this},t.prototype.reset=function(){for(var e=0;e<16;e++)this.m[e]=0;return this._markAsUpdated(),this},t.prototype.add=function(e){var i=new t;return this.addToRef(e,i),i},t.prototype.addToRef=function(e,t){for(var i=0;i<16;i++)t.m[i]=this.m[i]+e.m[i];return t._markAsUpdated(),this},t.prototype.addToSelf=function(e){for(var t=0;t<16;t++)this.m[t]+=e.m[t];return this._markAsUpdated(),this},t.prototype.invertToRef=function(e){var t=this.m[0],i=this.m[1],r=this.m[2],n=this.m[3],o=this.m[4],s=this.m[5],a=this.m[6],l=this.m[7],h=this.m[8],u=this.m[9],c=this.m[10],f=this.m[11],d=this.m[12],p=this.m[13],_=this.m[14],m=this.m[15],g=c*m-f*_,v=u*m-f*p,y=u*_-c*p,b=h*m-f*d,x=h*_-c*d,T=h*p-u*d,A=s*g-a*v+l*y,E=-(o*g-a*b+l*x),P=o*v-s*b+l*T,M=-(o*y-s*x+a*T),S=1/(t*A+i*E+r*P+n*M),C=a*m-l*_,R=s*m-l*p,O=s*_-a*p,I=o*m-l*d,D=o*_-a*d,B=o*p-s*d,L=a*f-l*c,w=s*f-l*u,F=s*c-a*u,N=o*f-l*h,V=o*c-a*h,U=o*u-s*h;return e.m[0]=A*S,e.m[4]=E*S,e.m[8]=P*S,e.m[12]=M*S,e.m[1]=-(i*g-r*v+n*y)*S,e.m[5]=(t*g-r*b+n*x)*S,e.m[9]=-(t*v-i*b+n*T)*S,e.m[13]=(t*y-i*x+r*T)*S,e.m[2]=(i*C-r*R+n*O)*S,e.m[6]=-(t*C-r*I+n*D)*S,e.m[10]=(t*R-i*I+n*B)*S,e.m[14]=-(t*O-i*D+r*B)*S,e.m[3]=-(i*L-r*w+n*F)*S,e.m[7]=(t*L-r*N+n*V)*S,e.m[11]=-(t*w-i*N+n*U)*S,e.m[15]=(t*F-i*V+r*U)*S,e._markAsUpdated(),this},t.prototype.setTranslationFromFloats=function(e,t,i){return this.m[12]=e,this.m[13]=t,this.m[14]=i,this._markAsUpdated(),this},t.prototype.setTranslation=function(e){return this.m[12]=e.x,this.m[13]=e.y,this.m[14]=e.z,this._markAsUpdated(),this},t.prototype.getTranslation=function(){return new n(this.m[12],this.m[13],this.m[14])},t.prototype.getTranslationToRef=function(e){return e.x=this.m[12],e.y=this.m[13],e.z=this.m[14],this},t.prototype.removeRotationAndScaling=function(){return this.setRowFromFloats(0,1,0,0,0),this.setRowFromFloats(1,0,1,0,0),this.setRowFromFloats(2,0,0,1,0),this},t.prototype.multiply=function(e){var i=new t;return this.multiplyToRef(e,i),i},t.prototype.copyFrom=function(e){for(var t=0;t<16;t++)this.m[t]=e.m[t];return this._markAsUpdated(),this},t.prototype.copyToArray=function(e,t){void 0===t&&(t=0);for(var i=0;i<16;i++)e[t+i]=this.m[i];return this},t.prototype.multiplyToRef=function(e,t){return this.multiplyToArray(e,t.m,0),t._markAsUpdated(),this},t.prototype.multiplyToArray=function(e,t,i){var r=this.m[0],n=this.m[1],o=this.m[2],s=this.m[3],a=this.m[4],l=this.m[5],h=this.m[6],u=this.m[7],c=this.m[8],f=this.m[9],d=this.m[10],p=this.m[11],_=this.m[12],m=this.m[13],g=this.m[14],v=this.m[15],y=e.m[0],b=e.m[1],x=e.m[2],T=e.m[3],A=e.m[4],E=e.m[5],P=e.m[6],M=e.m[7],S=e.m[8],C=e.m[9],R=e.m[10],O=e.m[11],I=e.m[12],D=e.m[13],B=e.m[14],L=e.m[15];return t[i]=r*y+n*A+o*S+s*I,t[i+1]=r*b+n*E+o*C+s*D,t[i+2]=r*x+n*P+o*R+s*B,t[i+3]=r*T+n*M+o*O+s*L,t[i+4]=a*y+l*A+h*S+u*I,t[i+5]=a*b+l*E+h*C+u*D,t[i+6]=a*x+l*P+h*R+u*B,t[i+7]=a*T+l*M+h*O+u*L,t[i+8]=c*y+f*A+d*S+p*I,t[i+9]=c*b+f*E+d*C+p*D,t[i+10]=c*x+f*P+d*R+p*B,t[i+11]=c*T+f*M+d*O+p*L,t[i+12]=_*y+m*A+g*S+v*I,t[i+13]=_*b+m*E+g*C+v*D,t[i+14]=_*x+m*P+g*R+v*B,t[i+15]=_*T+m*M+g*O+v*L,this},t.prototype.equals=function(e){return e&&this.m[0]===e.m[0]&&this.m[1]===e.m[1]&&this.m[2]===e.m[2]&&this.m[3]===e.m[3]&&this.m[4]===e.m[4]&&this.m[5]===e.m[5]&&this.m[6]===e.m[6]&&this.m[7]===e.m[7]&&this.m[8]===e.m[8]&&this.m[9]===e.m[9]&&this.m[10]===e.m[10]&&this.m[11]===e.m[11]&&this.m[12]===e.m[12]&&this.m[13]===e.m[13]&&this.m[14]===e.m[14]&&this.m[15]===e.m[15]},t.prototype.clone=function(){return t.FromValues(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5],this.m[6],this.m[7],this.m[8],this.m[9],this.m[10],this.m[11],this.m[12],this.m[13],this.m[14],this.m[15])},t.prototype.getClassName=function(){return"Matrix"},t.prototype.getHashCode=function(){for(var e=this.m[0]||0,t=1;t<16;t++)e=397*e^(this.m[t]||0);return e},t.prototype.decompose=function(e,i,r){return r.x=this.m[12],r.y=this.m[13],r.z=this.m[14],e.x=Math.sqrt(this.m[0]*this.m[0]+this.m[1]*this.m[1]+this.m[2]*this.m[2]),e.y=Math.sqrt(this.m[4]*this.m[4]+this.m[5]*this.m[5]+this.m[6]*this.m[6]),e.z=Math.sqrt(this.m[8]*this.m[8]+this.m[9]*this.m[9]+this.m[10]*this.m[10]),this.determinant()<=0&&(e.y*=-1),0===e.x||0===e.y||0===e.z?(i.x=0,i.y=0,i.z=0,i.w=1,!1):(t.FromValuesToRef(this.m[0]/e.x,this.m[1]/e.x,this.m[2]/e.x,0,this.m[4]/e.y,this.m[5]/e.y,this.m[6]/e.y,0,this.m[8]/e.z,this.m[9]/e.z,this.m[10]/e.z,0,0,0,0,1,A.Matrix[0]),a.FromRotationMatrixToRef(A.Matrix[0],i),!0)},t.prototype.getRotationMatrix=function(){var e=t.Identity();return this.getRotationMatrixToRef(e),e},t.prototype.getRotationMatrixToRef=function(e){var i=this.m,r=i[0]*i[1]*i[2]*i[3]<0?-1:1,n=i[4]*i[5]*i[6]*i[7]<0?-1:1,o=i[8]*i[9]*i[10]*i[11]<0?-1:1,s=r*Math.sqrt(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]),a=n*Math.sqrt(i[4]*i[4]+i[5]*i[5]+i[6]*i[6]),l=o*Math.sqrt(i[8]*i[8]+i[9]*i[9]+i[10]*i[10]);return t.FromValuesToRef(i[0]/s,i[1]/s,i[2]/s,0,i[4]/a,i[5]/a,i[6]/a,0,i[8]/l,i[9]/l,i[10]/l,0,0,0,0,1,e),this},t.FromArray=function(e,i){var r=new t;return i||(i=0),t.FromArrayToRef(e,i,r),r},t.FromArrayToRef=function(e,t,i){for(var r=0;r<16;r++)i.m[r]=e[r+t];i._markAsUpdated()},t.FromFloat32ArrayToRefScaled=function(e,t,i,r){for(var n=0;n<16;n++)r.m[n]=e[n+t]*i;r._markAsUpdated()},t.FromValuesToRef=function(e,t,i,r,n,o,s,a,l,h,u,c,f,d,p,_,m){m.m[0]=e,m.m[1]=t,m.m[2]=i,m.m[3]=r,m.m[4]=n,m.m[5]=o,m.m[6]=s,m.m[7]=a,m.m[8]=l,m.m[9]=h,m.m[10]=u,m.m[11]=c,m.m[12]=f,m.m[13]=d,m.m[14]=p,m.m[15]=_,m._markAsUpdated()},t.prototype.getRow=function(e){if(e<0||e>3)return null;var t=4*e;return new o(this.m[t+0],this.m[t+1],this.m[t+2],this.m[t+3])},t.prototype.setRow=function(e,t){if(e<0||e>3)return this;var i=4*e;return this.m[i+0]=t.x,this.m[i+1]=t.y,this.m[i+2]=t.z,this.m[i+3]=t.w,this._markAsUpdated(),this},t.prototype.transpose=function(){return t.Transpose(this)},t.prototype.transposeToRef=function(e){return t.TransposeToRef(this,e),this},t.prototype.setRowFromFloats=function(e,t,i,r,n){if(e<0||e>3)return this;var o=4*e;return this.m[o+0]=t,this.m[o+1]=i,this.m[o+2]=r,this.m[o+3]=n,this._markAsUpdated(),this},Object.defineProperty(t,"IdentityReadOnly",{get:function(){return t._identityReadOnly},enumerable:!0,configurable:!0}),t.FromValues=function(e,i,r,n,o,s,a,l,h,u,c,f,d,p,_,m){var g=new t;return g.m[0]=e,g.m[1]=i,g.m[2]=r,g.m[3]=n,g.m[4]=o,g.m[5]=s,g.m[6]=a,g.m[7]=l,g.m[8]=h,g.m[9]=u,g.m[10]=c,g.m[11]=f,g.m[12]=d,g.m[13]=p,g.m[14]=_,g.m[15]=m,g},t.Compose=function(e,i,r){var n=t.Identity();return t.ComposeToRef(e,i,r,n),n},t.ComposeToRef=function(e,i,r,n){t.FromValuesToRef(e.x,0,0,0,0,e.y,0,0,0,0,e.z,0,0,0,0,1,A.Matrix[1]),i.toRotationMatrix(A.Matrix[0]),A.Matrix[1].multiplyToRef(A.Matrix[0],n),n.setTranslation(r)},t.Identity=function(){return t.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},t.IdentityToRef=function(e){t.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,e)},t.Zero=function(){return t.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)},t.RotationX=function(e){var i=new t;return t.RotationXToRef(e,i),i},t.Invert=function(e){var i=new t;return e.invertToRef(i),i},t.RotationXToRef=function(e,t){var i=Math.sin(e),r=Math.cos(e);t.m[0]=1,t.m[15]=1,t.m[5]=r,t.m[10]=r,t.m[9]=-i,t.m[6]=i,t.m[1]=0,t.m[2]=0,t.m[3]=0,t.m[4]=0,t.m[7]=0,t.m[8]=0,t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0,t._markAsUpdated()},t.RotationY=function(e){var i=new t;return t.RotationYToRef(e,i),i},t.RotationYToRef=function(e,t){var i=Math.sin(e),r=Math.cos(e);t.m[5]=1,t.m[15]=1,t.m[0]=r,t.m[2]=-i,t.m[8]=i,t.m[10]=r,t.m[1]=0,t.m[3]=0,t.m[4]=0,t.m[6]=0,t.m[7]=0,t.m[9]=0,t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0,t._markAsUpdated()},t.RotationZ=function(e){var i=new t;return t.RotationZToRef(e,i),i},t.RotationZToRef=function(e,t){var i=Math.sin(e),r=Math.cos(e);t.m[10]=1,t.m[15]=1,t.m[0]=r,t.m[1]=i,t.m[4]=-i,t.m[5]=r,t.m[2]=0,t.m[3]=0,t.m[6]=0,t.m[7]=0,t.m[8]=0,t.m[9]=0,t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0,t._markAsUpdated()},t.RotationAxis=function(e,i){var r=t.Zero();return t.RotationAxisToRef(e,i,r),r},t.RotationAxisToRef=function(e,t,i){var r=Math.sin(-t),n=Math.cos(-t),o=1-n;e.normalize(),i.m[0]=e.x*e.x*o+n,i.m[1]=e.x*e.y*o-e.z*r,i.m[2]=e.x*e.z*o+e.y*r,i.m[3]=0,i.m[4]=e.y*e.x*o+e.z*r,i.m[5]=e.y*e.y*o+n,i.m[6]=e.y*e.z*o-e.x*r,i.m[7]=0,i.m[8]=e.z*e.x*o-e.y*r,i.m[9]=e.z*e.y*o+e.x*r,i.m[10]=e.z*e.z*o+n,i.m[11]=0,i.m[15]=1,i._markAsUpdated()},t.RotationYawPitchRoll=function(e,i,r){var n=new t;return t.RotationYawPitchRollToRef(e,i,r,n),n},t.RotationYawPitchRollToRef=function(e,t,i,r){a.RotationYawPitchRollToRef(e,t,i,this._tempQuaternion),this._tempQuaternion.toRotationMatrix(r)},t.Scaling=function(e,i,r){var n=t.Zero();return t.ScalingToRef(e,i,r,n),n},t.ScalingToRef=function(e,t,i,r){r.m[0]=e,r.m[1]=0,r.m[2]=0,r.m[3]=0,r.m[4]=0,r.m[5]=t,r.m[6]=0,r.m[7]=0,r.m[8]=0,r.m[9]=0,r.m[10]=i,r.m[11]=0,r.m[12]=0,r.m[13]=0,r.m[14]=0,r.m[15]=1,r._markAsUpdated()},t.Translation=function(e,i,r){var n=t.Identity();return t.TranslationToRef(e,i,r,n),n},t.TranslationToRef=function(e,i,r,n){t.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,e,i,r,1,n)},t.Lerp=function(e,i,r){for(var n=t.Zero(),o=0;o<16;o++)n.m[o]=e.m[o]*(1-r)+i.m[o]*r;return n._markAsUpdated(),n},t.DecomposeLerp=function(e,i,r){var o=new n(0,0,0),s=new a,l=new n(0,0,0);e.decompose(o,s,l);var h=new n(0,0,0),u=new a,c=new n(0,0,0);i.decompose(h,u,c);var f=n.Lerp(o,h,r),d=a.Slerp(s,u,r),p=n.Lerp(l,c,r);return t.Compose(f,d,p)},t.LookAtLH=function(e,i,r){var n=t.Zero();return t.LookAtLHToRef(e,i,r,n),n},t.LookAtLHToRef=function(e,i,r,o){i.subtractToRef(e,this._zAxis),this._zAxis.normalize(),n.CrossToRef(r,this._zAxis,this._xAxis),0===this._xAxis.lengthSquared()?this._xAxis.x=1:this._xAxis.normalize(),n.CrossToRef(this._zAxis,this._xAxis,this._yAxis),this._yAxis.normalize();var s=-n.Dot(this._xAxis,e),a=-n.Dot(this._yAxis,e),l=-n.Dot(this._zAxis,e);return t.FromValuesToRef(this._xAxis.x,this._yAxis.x,this._zAxis.x,0,this._xAxis.y,this._yAxis.y,this._zAxis.y,0,this._xAxis.z,this._yAxis.z,this._zAxis.z,0,s,a,l,1,o)},t.LookAtRH=function(e,i,r){var n=t.Zero();return t.LookAtRHToRef(e,i,r,n),n},t.LookAtRHToRef=function(e,i,r,o){e.subtractToRef(i,this._zAxis),this._zAxis.normalize(),n.CrossToRef(r,this._zAxis,this._xAxis),0===this._xAxis.lengthSquared()?this._xAxis.x=1:this._xAxis.normalize(),n.CrossToRef(this._zAxis,this._xAxis,this._yAxis),this._yAxis.normalize();var s=-n.Dot(this._xAxis,e),a=-n.Dot(this._yAxis,e),l=-n.Dot(this._zAxis,e);return t.FromValuesToRef(this._xAxis.x,this._yAxis.x,this._zAxis.x,0,this._xAxis.y,this._yAxis.y,this._zAxis.y,0,this._xAxis.z,this._yAxis.z,this._zAxis.z,0,s,a,l,1,o)},t.OrthoLH=function(e,i,r,n){var o=t.Zero();return t.OrthoLHToRef(e,i,r,n,o),o},t.OrthoLHToRef=function(t,i,r,n,o){var s=r,a=n,l=2/t,h=2/i,u=2/(a-s),c=-(a+s)/(a-s);e.Matrix.FromValuesToRef(l,0,0,0,0,h,0,0,0,0,u,0,0,0,c,1,o)},t.OrthoOffCenterLH=function(e,i,r,n,o,s){var a=t.Zero();return t.OrthoOffCenterLHToRef(e,i,r,n,o,s,a),a},t.OrthoOffCenterLHToRef=function(t,i,r,n,o,s,a){var l=o,h=s,u=2/(i-t),c=2/(n-r),f=2/(h-l),d=-(h+l)/(h-l),p=(t+i)/(t-i),_=(n+r)/(r-n);e.Matrix.FromValuesToRef(u,0,0,0,0,c,0,0,0,0,f,0,p,_,d,1,a)},t.OrthoOffCenterRH=function(e,i,r,n,o,s){var a=t.Zero();return t.OrthoOffCenterRHToRef(e,i,r,n,o,s,a),a},t.OrthoOffCenterRHToRef=function(e,i,r,n,o,s,a){t.OrthoOffCenterLHToRef(e,i,r,n,o,s,a),a.m[10]*=-1},t.PerspectiveLH=function(i,r,n,o){var s=t.Zero(),a=n,l=o,h=2*a/i,u=2*a/r,c=(l+a)/(l-a),f=-2*l*a/(l-a);return e.Matrix.FromValuesToRef(h,0,0,0,0,u,0,0,0,0,c,1,0,0,f,0,s),s},t.PerspectiveFovLH=function(e,i,r,n){var o=t.Zero();return t.PerspectiveFovLHToRef(e,i,r,n,o),o},t.PerspectiveFovLHToRef=function(t,i,r,n,o,s){void 0===s&&(s=!0);var a=r,l=n,h=1/Math.tan(.5*t),u=s?h/i:h,c=s?h:h*i,f=(l+a)/(l-a),d=-2*l*a/(l-a);e.Matrix.FromValuesToRef(u,0,0,0,0,c,0,0,0,0,f,1,0,0,d,0,o)},t.PerspectiveFovRH=function(e,i,r,n){var o=t.Zero();return t.PerspectiveFovRHToRef(e,i,r,n,o),o},t.PerspectiveFovRHToRef=function(t,i,r,n,o,s){void 0===s&&(s=!0);var a=r,l=n,h=1/Math.tan(.5*t),u=s?h/i:h,c=s?h:h*i,f=-(l+a)/(l-a),d=-2*l*a/(l-a);e.Matrix.FromValuesToRef(u,0,0,0,0,c,0,0,0,0,f,-1,0,0,d,0,o)},t.PerspectiveFovWebVRToRef=function(e,t,i,r,n){void 0===n&&(n=!1);var o=n?-1:1,s=Math.tan(e.upDegrees*Math.PI/180),a=Math.tan(e.downDegrees*Math.PI/180),l=Math.tan(e.leftDegrees*Math.PI/180),h=Math.tan(e.rightDegrees*Math.PI/180),u=2/(l+h),c=2/(s+a);r.m[0]=u,r.m[1]=r.m[2]=r.m[3]=r.m[4]=0,r.m[5]=c,r.m[6]=r.m[7]=0,r.m[8]=(l-h)*u*.5,r.m[9]=-(s-a)*c*.5,r.m[10]=-i/(t-i),r.m[11]=1*o,r.m[12]=r.m[13]=r.m[15]=0,r.m[14]=-2*i*t/(i-t),r._markAsUpdated()},t.GetFinalMatrix=function(e,i,r,n,o,s){var a=e.width,l=e.height,h=e.x,u=e.y,c=t.FromValues(a/2,0,0,0,0,-l/2,0,0,0,0,s-o,0,h+a/2,l/2+u,o,1);return i.multiply(r).multiply(n).multiply(c)},t.GetAsMatrix2x2=function(e){return new Float32Array([e.m[0],e.m[1],e.m[4],e.m[5]])},t.GetAsMatrix3x3=function(e){return new Float32Array([e.m[0],e.m[1],e.m[2],e.m[4],e.m[5],e.m[6],e.m[8],e.m[9],e.m[10]])},t.Transpose=function(e){var i=new t;return t.TransposeToRef(e,i),i},t.TransposeToRef=function(e,t){t.m[0]=e.m[0],t.m[1]=e.m[4],t.m[2]=e.m[8],t.m[3]=e.m[12],t.m[4]=e.m[1],t.m[5]=e.m[5],t.m[6]=e.m[9],t.m[7]=e.m[13],t.m[8]=e.m[2],t.m[9]=e.m[6],t.m[10]=e.m[10],t.m[11]=e.m[14],t.m[12]=e.m[3],t.m[13]=e.m[7],t.m[14]=e.m[11],t.m[15]=e.m[15]},t.Reflection=function(e){var i=new t;return t.ReflectionToRef(e,i),i},t.ReflectionToRef=function(e,t){e.normalize();var i=e.normal.x,r=e.normal.y,n=e.normal.z,o=-2*i,s=-2*r,a=-2*n;t.m[0]=o*i+1,t.m[1]=s*i,t.m[2]=a*i,t.m[3]=0,t.m[4]=o*r,t.m[5]=s*r+1,t.m[6]=a*r,t.m[7]=0,t.m[8]=o*n,t.m[9]=s*n,t.m[10]=a*n+1,t.m[11]=0,t.m[12]=o*e.d,t.m[13]=s*e.d,t.m[14]=a*e.d,t.m[15]=1,t._markAsUpdated()},t.FromXYZAxesToRef=function(e,t,i,r){r.m[0]=e.x,r.m[1]=e.y,r.m[2]=e.z,r.m[3]=0,r.m[4]=t.x,r.m[5]=t.y,r.m[6]=t.z,r.m[7]=0,r.m[8]=i.x,r.m[9]=i.y,r.m[10]=i.z,r.m[11]=0,r.m[12]=0,r.m[13]=0,r.m[14]=0,r.m[15]=1,r._markAsUpdated()},t.FromQuaternionToRef=function(e,t){var i=e.x*e.x,r=e.y*e.y,n=e.z*e.z,o=e.x*e.y,s=e.z*e.w,a=e.z*e.x,l=e.y*e.w,h=e.y*e.z,u=e.x*e.w;t.m[0]=1-2*(r+n),t.m[1]=2*(o+s),t.m[2]=2*(a-l),t.m[3]=0,t.m[4]=2*(o-s),t.m[5]=1-2*(n+i),t.m[6]=2*(h+u),t.m[7]=0,t.m[8]=2*(a+l),t.m[9]=2*(h-u),t.m[10]=1-2*(r+i),t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0,t.m[15]=1,t._markAsUpdated()},t._tempQuaternion=new a,t._xAxis=n.Zero(),t._yAxis=n.Zero(),t._zAxis=n.Zero(),t._updateFlagSeed=0,t._identityReadOnly=t.Identity(),t})();e.Matrix=l;var h=(function(){function e(e,t,i,r){this.normal=new n(e,t,i),this.d=r}return e.prototype.asArray=function(){return[this.normal.x,this.normal.y,this.normal.z,this.d]},e.prototype.clone=function(){return new e(this.normal.x,this.normal.y,this.normal.z,this.d)},e.prototype.getClassName=function(){return"Plane"},e.prototype.getHashCode=function(){var e=this.normal.getHashCode();return e=397*e^(this.d||0)},e.prototype.normalize=function(){var e=Math.sqrt(this.normal.x*this.normal.x+this.normal.y*this.normal.y+this.normal.z*this.normal.z),t=0;return 0!==e&&(t=1/e),this.normal.x*=t,this.normal.y*=t,this.normal.z*=t,this.d*=t,this},e.prototype.transform=function(t){var i=l.Transpose(t),r=this.normal.x,n=this.normal.y,o=this.normal.z,s=this.d;return new e(r*i.m[0]+n*i.m[1]+o*i.m[2]+s*i.m[3],r*i.m[4]+n*i.m[5]+o*i.m[6]+s*i.m[7],r*i.m[8]+n*i.m[9]+o*i.m[10]+s*i.m[11],r*i.m[12]+n*i.m[13]+o*i.m[14]+s*i.m[15])},e.prototype.dotCoordinate=function(e){return this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z+this.d},e.prototype.copyFromPoints=function(e,t,i){var r,n=t.x-e.x,o=t.y-e.y,s=t.z-e.z,a=i.x-e.x,l=i.y-e.y,h=i.z-e.z,u=o*h-s*l,c=s*a-n*h,f=n*l-o*a,d=Math.sqrt(u*u+c*c+f*f);return r=0!==d?1/d:0,this.normal.x=u*r,this.normal.y=c*r,this.normal.z=f*r,this.d=-(this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z),this},e.prototype.isFrontFacingTo=function(e,t){return n.Dot(this.normal,e)<=t},e.prototype.signedDistanceTo=function(e){return n.Dot(e,this.normal)+this.d},e.FromArray=function(t){return new e(t[0],t[1],t[2],t[3])},e.FromPoints=function(t,i,r){var n=new e(0,0,0,0);return n.copyFromPoints(t,i,r),n},e.FromPositionAndNormal=function(t,i){var r=new e(0,0,0,0);return i.normalize(),r.normal=i,r.d=-(i.x*t.x+i.y*t.y+i.z*t.z),r},e.SignedDistanceToPlaneFromPositionAndNormal=function(e,t,i){var r=-(t.x*e.x+t.y*e.y+t.z*e.z);return n.Dot(i,t)+r},e})();e.Plane=h;var u=(function(){function e(e,t,i,r){this.x=e,this.y=t,this.width=i,this.height=r}return e.prototype.toGlobal=function(t,i){if(t.getRenderWidth){var r=t;return this.toGlobal(r.getRenderWidth(),r.getRenderHeight())}var n=t;return new e(this.x*n,this.y*i,this.width*n,this.height*i)},e.prototype.clone=function(){return new e(this.x,this.y,this.width,this.height)},e})();e.Viewport=u;var c=(function(){function e(){}return e.GetPlanes=function(t){for(var i=[],r=0;r<6;r++)i.push(new h(0,0,0,0));return e.GetPlanesToRef(t,i),i},e.GetNearPlaneToRef=function(e,t){t.normal.x=e.m[3]+e.m[2],t.normal.y=e.m[7]+e.m[6],t.normal.z=e.m[11]+e.m[10],t.d=e.m[15]+e.m[14],t.normalize()},e.GetFarPlaneToRef=function(e,t){t.normal.x=e.m[3]-e.m[2],t.normal.y=e.m[7]-e.m[6],t.normal.z=e.m[11]-e.m[10],t.d=e.m[15]-e.m[14],t.normalize()},e.GetLeftPlaneToRef=function(e,t){t.normal.x=e.m[3]+e.m[0],t.normal.y=e.m[7]+e.m[4],t.normal.z=e.m[11]+e.m[8],t.d=e.m[15]+e.m[12],t.normalize()},e.GetRightPlaneToRef=function(e,t){t.normal.x=e.m[3]-e.m[0],t.normal.y=e.m[7]-e.m[4],t.normal.z=e.m[11]-e.m[8],t.d=e.m[15]-e.m[12],t.normalize()},e.GetTopPlaneToRef=function(e,t){t.normal.x=e.m[3]-e.m[1],t.normal.y=e.m[7]-e.m[5],t.normal.z=e.m[11]-e.m[9],t.d=e.m[15]-e.m[13],t.normalize()},e.GetBottomPlaneToRef=function(e,t){t.normal.x=e.m[3]+e.m[1],t.normal.y=e.m[7]+e.m[5],t.normal.z=e.m[11]+e.m[9],t.d=e.m[15]+e.m[13],t.normalize()},e.GetPlanesToRef=function(t,i){e.GetNearPlaneToRef(t,i[0]),e.GetFarPlaneToRef(t,i[1]),e.GetLeftPlaneToRef(t,i[2]),e.GetRightPlaneToRef(t,i[3]),e.GetTopPlaneToRef(t,i[4]),e.GetBottomPlaneToRef(t,i[5])},e})();e.Frustum=c;!(function(e){e[e.LOCAL=0]="LOCAL",e[e.WORLD=1]="WORLD",e[e.BONE=2]="BONE"})(e.Space||(e.Space={}));var f=(function(){function e(){}return e.X=new n(1,0,0),e.Y=new n(0,1,0),e.Z=new n(0,0,1),e})();e.Axis=f;var d=(function(){function e(){}return e.interpolate=function(e,t,i,r,n){for(var o=1-3*r+3*t,s=3*r-6*t,a=3*t,l=e,h=0;h<5;h++){var u=l*l;l-=(o*(u*l)+s*u+a*l-e)*(1/(3*o*u+2*s*l+a)),l=Math.min(1,Math.max(0,l))}return 3*Math.pow(1-l,2)*l*i+3*(1-l)*Math.pow(l,2)*n+Math.pow(l,3)},e})();e.BezierCurve=d;var p;!(function(e){e[e.CW=0]="CW",e[e.CCW=1]="CCW"})(p=e.Orientation||(e.Orientation={}));var _=(function(){function e(e){var t=this;this.degrees=function(){return 180*t._radians/Math.PI},this.radians=function(){return t._radians},this._radians=e,this._radians<0&&(this._radians+=2*Math.PI)}return e.BetweenTwoPoints=function(t,i){var r=i.subtract(t);return new e(Math.atan2(r.y,r.x))},e.FromRadians=function(t){return new e(t)},e.FromDegrees=function(t){return new e(t*Math.PI/180)},e})();e.Angle=_;var m=(function(){function e(e,t,i){this.startPoint=e,this.midPoint=t,this.endPoint=i;var n=Math.pow(t.x,2)+Math.pow(t.y,2),o=(Math.pow(e.x,2)+Math.pow(e.y,2)-n)/2,s=(n-Math.pow(i.x,2)-Math.pow(i.y,2))/2,a=(e.x-t.x)*(t.y-i.y)-(t.x-i.x)*(e.y-t.y);this.centerPoint=new r((o*(t.y-i.y)-s*(e.y-t.y))/a,((e.x-t.x)*s-(t.x-i.x)*o)/a),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=_.BetweenTwoPoints(this.centerPoint,this.startPoint);var l=this.startAngle.degrees(),h=_.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),u=_.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();h-l>180&&(h-=360),h-l<-180&&(h+=360),u-h>180&&(u-=360),u-h<-180&&(u+=360),this.orientation=h-l<0?p.CW:p.CCW,this.angle=_.FromDegrees(this.orientation===p.CW?l-u:u-l)}return e})();e.Arc2=m;var g=(function(){function e(e,t){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new r(e,t))}return e.prototype.addLineTo=function(e,t){if(this.closed)return this;var i=new r(e,t),n=this._points[this._points.length-1];return this._points.push(i),this._length+=i.subtract(n).length(),this},e.prototype.addArcTo=function(e,t,i,n,o){if(void 0===o&&(o=36),this.closed)return this;var s=this._points[this._points.length-1],a=new r(e,t),l=new r(i,n),h=new m(s,a,l),u=h.angle.radians()/o;h.orientation===p.CW&&(u*=-1);for(var c=h.startAngle.radians()+u,f=0;f1)return r.Zero();for(var t=e*this.length(),i=0,n=0;n=i&&t<=h){var u=l.normalize(),c=t-i;return new r(s.x+u.x*c,s.y+u.y*c)}i=h}return r.Zero()},e.StartingAt=function(t,i){return new e(t,i)},e})();e.Path2=g;var v=(function(){function t(e,t,i){void 0===t&&(t=null),this.path=e,this._curve=new Array,this._distances=new Array,this._tangents=new Array,this._normals=new Array,this._binormals=new Array;for(var r=0;rt+1;)t++,i=this._curve[e].subtract(this._curve[e-t]);return i},t.prototype._normalVector=function(t,i,r){var o,s=i.length();if(0===s&&(s=1),void 0===r||null===r){var a;a=e.Scalar.WithinEpsilon(Math.abs(i.y)/s,1,e.Epsilon)?e.Scalar.WithinEpsilon(Math.abs(i.x)/s,1,e.Epsilon)?e.Scalar.WithinEpsilon(Math.abs(i.z)/s,1,e.Epsilon)?n.Zero():new n(0,0,1):new n(1,0,0):new n(0,-1,0),o=n.Cross(i,a)}else o=n.Cross(i,r),n.CrossToRef(o,i,o);return o.normalize(),o},t})();e.Path3D=v;var y=(function(){function e(e){this._length=0,this._points=e,this._length=this._computeLength(e)}return e.CreateQuadraticBezier=function(t,i,r,o){o=o>2?o:3;for(var s=new Array,a=function(e,t,i,r){return(1-e)*(1-e)*t+2*e*(1-e)*i+e*e*r},l=0;l<=o;l++)s.push(new n(a(l/o,t.x,i.x,r.x),a(l/o,t.y,i.y,r.y),a(l/o,t.z,i.z,r.z)));return new e(s)},e.CreateCubicBezier=function(t,i,r,o,s){s=s>3?s:4;for(var a=new Array,l=function(e,t,i,r,n){return(1-e)*(1-e)*(1-e)*t+3*e*(1-e)*(1-e)*i+3*e*e*(1-e)*r+e*e*e*n},h=0;h<=s;h++)a.push(new n(l(h/s,t.x,i.x,r.x,o.x),l(h/s,t.y,i.y,r.y,o.y),l(h/s,t.z,i.z,r.z,o.z)));return new e(a)},e.CreateHermiteSpline=function(t,i,r,o,s){for(var a=new Array,l=1/s,h=0;h<=s;h++)a.push(n.Hermite(t,i,r,o,h*l));return new e(a)},e.CreateCatmullRomSpline=function(t,i){var r=new Array;r.push(t[0].clone()),Array.prototype.push.apply(r,t),r.push(t[t.length-1].clone());for(var o=new Array,s=1/i,a=0,l=0;l0?1:-1},e.Clamp=function(e,t,i){return void 0===t&&(t=0),void 0===i&&(i=1),Math.min(i,Math.max(t,e))},e.Log2=function(e){return Math.log(e)*Math.LOG2E},e.Repeat=function(e,t){return e-Math.floor(e/t)*t},e.Normalize=function(e,t,i){return(e-t)/(i-t)},e.Denormalize=function(e,t,i){return e*(i-t)+t},e.DeltaAngle=function(t,i){var r=e.Repeat(i-t,360);return r>180&&(r-=360),r},e.PingPong=function(t,i){var r=e.Repeat(t,2*i);return i-Math.abs(r-i)},e.SmoothStep=function(t,i,r){var n=e.Clamp(r);return n=-2*n*n*n+3*n*n,i*n+t*(1-n)},e.MoveTowards=function(t,i,r){return Math.abs(i-t)<=r?i:t+e.Sign(i-t)*r},e.MoveTowardsAngle=function(t,i,r){var n=e.DeltaAngle(t,i),o=0;return-r180&&(n-=360),t+n*e.Clamp(r)},e.InverseLerp=function(t,i,r){return t!=i?e.Clamp((r-t)/(i-t)):0},e.Hermite=function(e,t,i,r,n){var o=n*n,s=n*o;return e*(2*s-3*o+1)+i*(-2*s+3*o)+t*(s-2*o+n)+r*(s-o)},e.RandomRange=function(e,t){return e===t?e:Math.random()*(t-e)+e},e.RangeToPercent=function(e,t,i){return(e-t)/(i-t)},e.PercentToRange=function(e,t,i){return(i-t)*e+t},e.NormalizeRadians=function(t){return t-=e.TwoPi*Math.floor((t+Math.PI)/e.TwoPi)},e.TwoPi=2*Math.PI,e})();e.Scalar=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){function t(e){var t=e.getClassName();return m[t]||(m[t]={}),m[t]}function i(e){var t=e.getClassName();if(g[t])return g[t];g[t]={};for(var i=g[t],r=e,n=t;n;){var o=m[n];for(var s in o)i[s]=o[s];var a=void 0,l=!1;do{if(a=Object.getPrototypeOf(r),!a.getClassName){l=!0;break}if(a.getClassName()!==n)break;r=a}while(a);if(l)break;n=a.getClassName(),r=a}return i}function r(e,i){return function(r,n){var o=t(r);o[n]||(o[n]={type:e,sourceName:i})}}function n(e,t){return void 0===t&&(t=null),function(i,r){var n=t||"_"+r;Object.defineProperty(i,r,{get:function(){return this[n]},set:function(t){this[n]!==t&&(this[n]=t,i[e].apply(this))},enumerable:!0,configurable:!0})}}function o(e,t){return void 0===t&&(t=null),n(e,t)}function s(e){return r(0,e)}function a(e){return r(1,e)}function l(e){return r(2,e)}function h(e){return r(3,e)}function u(e){return r(4,e)}function c(e){return r(5,e)}function f(e){return r(6,e)}function d(e){return r(7,e)}function p(e){return r(8,e)}function _(e){return r(9,e)}var m={},g={},v=function(t,r,n){var o=t();e.Tags&&e.Tags.AddTagsTo(o,r.tags);var s=i(o);for(var a in s){var l=s[a],h=r[a],u=l.type;if(void 0!==h&&null!==h)switch(u){case 0:case 6:o[a]=h;break;case 1:o[a]=n||h.isRenderTarget?h:h.clone();break;case 2:case 3:case 4:case 5:case 7:o[a]=n?h:h.clone()}}return o};e.expandToProperty=o,e.serialize=s,e.serializeAsTexture=a,e.serializeAsColor3=l, e.serializeAsFresnelParameters=h,e.serializeAsVector2=u,e.serializeAsVector3=c,e.serializeAsMeshReference=f,e.serializeAsColorCurves=d,e.serializeAsColor4=p,e.serializeAsImageProcessingConfiguration=_;var y=(function(){function t(){}return t.Serialize=function(t,r){r||(r={}),e.Tags&&(r.tags=e.Tags.GetTags(t));var n=i(t);for(var o in n){var s=n[o],a=s.sourceName||o,l=s.type,h=t[o];if(void 0!==h&&null!==h)switch(l){case 0:r[a]=h;break;case 1:r[a]=h.serialize();break;case 2:r[a]=h.asArray();break;case 3:r[a]=h.serialize();break;case 4:case 5:r[a]=h.asArray();break;case 6:r[a]=h.id;break;case 7:r[a]=h.serialize();break;case 8:r[a]=h.asArray();break;case 9:r[a]=h.serialize()}}return r},t.Parse=function(t,r,n,o){void 0===o&&(o=null);var s=t();o||(o=""),e.Tags&&e.Tags.AddTagsTo(s,r.tags);var a=i(s);for(var l in a){var h=a[l],u=r[h.sourceName||l],c=h.type;if(void 0!==u&&null!==u){var f=s;switch(c){case 0:f[l]=u;break;case 1:n&&(f[l]=e.Texture.Parse(u,n,o));break;case 2:f[l]=e.Color3.FromArray(u);break;case 3:f[l]=e.FresnelParameters.Parse(u);break;case 4:f[l]=e.Vector2.FromArray(u);break;case 5:f[l]=e.Vector3.FromArray(u);break;case 6:n&&(f[l]=n.getLastMeshByID(u));break;case 7:f[l]=e.ColorCurves.Parse(u);break;case 8:f[l]=e.Color4.FromArray(u);break;case 9:f[l]=e.ImageProcessingConfiguration.Parse(u)}}}return s},t.Clone=function(e,t){return v(e,t,!1)},t.Instanciate=function(e,t){return v(e,t,!0)},t})();e.SerializationHelper=y})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e,t,i,r){void 0===t&&(t=!1),this.initalize(e,t,i,r)}return e.prototype.initalize=function(e,t,i,r){return void 0===t&&(t=!1),this.mask=e,this.skipNextObservers=t,this.target=i,this.currentTarget=r,this},e})();e.EventState=t;var i=(function(){function e(e,t,i){void 0===i&&(i=null),this.callback=e,this.mask=t,this.scope=i}return e})();e.Observer=i;var r=(function(){function e(){}return e.prototype.dispose=function(){if(this._observers&&this._observables)for(var e=0;e0},e.prototype.clear=function(){this._observers=new Array,this._onObserverAdded=null},e.prototype.clone=function(){var t=new e;return t._observers=this._observers.slice(0),t},e.prototype.hasSpecificMask=function(e){void 0===e&&(e=-1);for(var t=0,i=this._observers;tthis.data.length&&(this.data.length*=2)},e.prototype.forEach=function(e){for(var t=0;tthis.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t=this.length?-1:t},e.prototype.contains=function(e){return-1!==this.data.indexOf(e)},e._GlobalId=0,e})();e.SmartArray=t;var i=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._duplicateId=0,t}return __extends(t,e),t.prototype.push=function(t){e.prototype.push.call(this,t),t.__smartArrayFlags||(t.__smartArrayFlags={}),t.__smartArrayFlags[this._id]=this._duplicateId},t.prototype.pushNoDuplicate=function(e){return(!e.__smartArrayFlags||e.__smartArrayFlags[this._id]!==this._duplicateId)&&(this.push(e),!0)},t.prototype.reset=function(){e.prototype.reset.call(this),this._duplicateId++},t.prototype.concatWithNoDuplicate=function(e){if(0!==e.length){this.length+e.length>this.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e},t.FloorPOT=function(e){return e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,(e|=e>>16)-(e>>1)},t.NearestPOT=function(e){var i=t.CeilingPOT(e),r=t.FloorPOT(e);return i-e>e-r?r:i},t.GetExponentOfTwo=function(i,r,n){void 0===n&&(n=e.Engine.SCALEMODE_NEAREST);var o;switch(n){case e.Engine.SCALEMODE_FLOOR:o=t.FloorPOT(i);break;case e.Engine.SCALEMODE_NEAREST:o=t.NearestPOT(i);break;case e.Engine.SCALEMODE_CEILING:default:o=t.CeilingPOT(i)}return Math.min(o,r)},t.GetFilename=function(e){var t=e.lastIndexOf("/");return t<0?e:e.substring(t+1)},t.GetFolderPath=function(e){var t=e.lastIndexOf("/");return t<0?"":e.substring(0,t+1)},t.GetDOMTextContent=function(e){for(var t="",i=e.firstChild;i;)3===i.nodeType&&(t+=i.textContent),i=i.nextSibling;return t},t.ToDegrees=function(e){return 180*e/Math.PI},t.ToRadians=function(e){return e*Math.PI/180},t.EncodeArrayBufferTobase64=function(e){for(var t,i,r,n,o,s,a,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",h="",u=0,c=new Uint8Array(e);u>2,o=(3&t)<<4|i>>4,s=(15&i)<<2|r>>6,a=63&r,isNaN(i)?s=a=64:isNaN(r)&&(a=64),h+=l.charAt(n)+l.charAt(o)+l.charAt(s)+l.charAt(a);return"data:image/png;base64,"+h},t.ExtractMinAndMaxIndexed=function(t,i,r,n,o){void 0===o&&(o=null);for(var s=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),a=new e.Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),l=r;l=(r?t.length/2:t.length))return null;if(r){var n=t;return new e.Vector2(n[2*i+0],n[2*i+1])}return t[i]}},t.ExtractMinAndMaxVector2=function(t,i){void 0===i&&(i=null);for(var r=new e.Vector2(Number.MAX_VALUE,Number.MAX_VALUE),n=new e.Vector2(-Number.MAX_VALUE,-Number.MAX_VALUE),o=0,s=t(o++);s;)r=e.Vector2.Minimize(s,r),n=e.Vector2.Maximize(s,n),s=t(o++);return i&&(r.x-=r.x*i.x+i.y,r.y-=r.y*i.x+i.y,n.x+=n.x*i.x+i.y,n.y+=n.y*i.x+i.y),{minimum:r,maximum:n}},t.MakeArray=function(e,t){return!0===t||void 0!==e&&null!=e?Array.isArray(e)?e:[e]:null},t.GetPointerPrefix=function(){var e="pointer";return!t.IsWindowObjectExist()||window.PointerEvent||navigator.pointerEnabled||(e="mouse"),e},t.QueueNewFrame=function(e,i){return t.IsWindowObjectExist()?(i||(i=window),i.requestAnimationFrame?i.requestAnimationFrame(e):i.msRequestAnimationFrame?i.msRequestAnimationFrame(e):i.webkitRequestAnimationFrame?i.webkitRequestAnimationFrame(e):i.mozRequestAnimationFrame?i.mozRequestAnimationFrame(e):i.oRequestAnimationFrame?i.oRequestAnimationFrame(e):window.setTimeout(e,16)):setTimeout(e,16)},t.RequestFullscreen=function(e){var t=e.requestFullscreen||e.msRequestFullscreen||e.webkitRequestFullscreen||e.mozRequestFullScreen;t&&t.call(e)},t.ExitFullscreen=function(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen?document.webkitCancelFullScreen():document.msCancelFullScreen&&document.msCancelFullScreen()},t.SetCorsBehavior=function(e,i){if(t.CorsBehavior)switch(typeof t.CorsBehavior){case"function":var r=t.CorsBehavior(e);r&&(i.crossOrigin=r);break;case"string":default:i.crossOrigin=t.CorsBehavior}},t.CleanUrl=function(e){return e=e.replace(/#/gm,"%23")},t.LoadImage=function(i,r,n,o){i instanceof ArrayBuffer&&(i=t.EncodeArrayBufferTobase64(i)),i=t.CleanUrl(i),i=t.PreprocessUrl(i);var s=new Image;"data:"!==i.substr(0,5)&&t.SetCorsBehavior(i,s),s.onload=function(){r(s)},s.onerror=function(e){t.Error("Error while trying to load image: "+i),t.UseFallbackTexture?(s.src=t.fallbackTexture,r(s)):n("Error while trying to load image: "+i,e)};var a=function(){s.src=i},l=function(){o&&o.loadImageFromDB(i,s)};if("data:"!==i.substr(0,5)&&o&&o.enableTexturesOffline&&e.Database.IsUASupportingBlobStorage)o.openAsync(l,a);else if(0!==i.indexOf("file:"))a();else{var h=decodeURIComponent(i.substring(5).toLowerCase());if(e.FilesInput.FilesToLoad[h])try{var u;try{u=URL.createObjectURL(e.FilesInput.FilesToLoad[h],{oneTimeOnly:!0})}catch(t){u=URL.createObjectURL(e.FilesInput.FilesToLoad[h])}s.src=u}catch(e){s.src=""}else t.Error("Image: "+h+" not found. Did you forget to provide it?"),s.src=t.fallbackTexture}return s},t.LoadFile=function(i,r,n,o,s,a){i=t.CleanUrl(i),i=t.PreprocessUrl(i);var l=null,h=function(){l=new XMLHttpRequest;var e=t.BaseUrl+i;l.open("GET",e,!0),s&&(l.responseType="arraybuffer"),n&&(l.onprogress=n),l.onreadystatechange=function(){var i=l;if(i.readyState===(XMLHttpRequest.DONE||4))if(i.onreadystatechange=function(){},i.status>=200&&i.status<300||!t.IsWindowObjectExist()&&0===i.status)r(s?i.response:i.responseText,i.responseURL);else{var n=new Error("Error status: "+i.status+" - Unable to load "+e);if(!a)throw n;a(i,n)}},l.send(null)},u=function(){o&&o.loadFileFromDB(i,r,n,h,s)};if(-1!==i.indexOf("file:")){var c=decodeURIComponent(i.substring(5).toLowerCase());if(e.FilesInput.FilesToLoad[c])t.ReadFile(e.FilesInput.FilesToLoad[c],r,n,s);else{var f="File: "+c+" not found. Did you forget to provide it?";if(a){var d=new Error(f);a(void 0,d)}else t.Error(f)}}else o&&o.enableSceneOffline?o.openAsync(u,h):h();return l},t.LoadScript=function(e,t,i){var r=document.getElementsByTagName("head")[0],n=document.createElement("script");n.type="text/javascript",n.src=e,n.onload=function(){t&&t()},n.onerror=function(e){i&&i("Unable to load script",e)},r.appendChild(n)},t.ReadFileAsDataURL=function(e,t,i){var r=new FileReader;r.onload=function(e){t(e.target.result)},r.onprogress=i,r.readAsDataURL(e)},t.ReadFile=function(e,i,r,n){var o=new FileReader;o.onerror=function(r){t.Log("Error while reading file: "+e.name),i(JSON.stringify({autoClear:!0,clearColor:[1,0,0],ambientColor:[0,0,0],gravity:[0,-9.807,0],meshes:[],cameras:[],lights:[]}))},o.onload=function(e){i(e.target.result)},r&&(o.onprogress=r),n?o.readAsArrayBuffer(e):o.readAsText(e)},t.FileAsURL=function(e){var t=new Blob([e]);return(window.URL||window.webkitURL).createObjectURL(t)},t.Format=function(e,t){return void 0===t&&(t=2),e.toFixed(t)},t.CheckExtends=function(e,t,i){e.xi.x&&(i.x=e.x),e.y>i.y&&(i.y=e.y),e.z>i.z&&(i.z=e.z)},t.DeepCopy=function(e,t,i,n){for(var o in e)if(("_"!==o[0]||n&&-1!==n.indexOf(o))&&(!i||-1===i.indexOf(o))){var s=e[o],a=typeof s;if("function"!==a)if("object"===a)if(s instanceof Array){if(t[o]=[],s.length>0)if("object"==typeof s[0])for(var l=0;ll&&(f=l,c=f*u);var d=Math.max(0,a-c)/2,p=Math.max(0,l-f)/2,_=e.getRenderingCanvas();h&&_&&h.drawImage(_,d,p,c,f),t.EncodeScreenshotCanvasData(o,s)},t.CreateScreenshotUsingRenderTarget=function(i,r,n,o,s,a){void 0===s&&(s="image/png"),void 0===a&&(a=1);var l,h;if(n.precision)l=Math.round(i.getRenderWidth()*n.precision),h=Math.round(l/i.getAspectRatio(r)),n={width:l,height:h};else if(n.width&&n.height)l=n.width,h=n.height;else if(n.width&&!n.height)l=n.width,h=Math.round(l/i.getAspectRatio(r)),n={width:l,height:h};else if(n.height&&!n.width)h=n.height,l=Math.round(h*i.getAspectRatio(r)),n={width:l,height:h};else{if(isNaN(n))return void t.Error("Invalid 'size' parameter !");h=n,l=n}var u=r.getScene(),c=null;u.activeCamera!==r&&(c=u.activeCamera,u.activeCamera=r);var f=new e.RenderTargetTexture("screenShot",n,u,!1,!1,e.Engine.TEXTURETYPE_UNSIGNED_INT,!1,e.Texture.NEAREST_SAMPLINGMODE);f.renderList=null,f.samples=a,f.onAfterRenderObservable.add((function(){t.DumpFramebuffer(l,h,i,o,s)})),u.incrementRenderId(),u.resetCachedMaterial(),f.render(!0),f.dispose(),c&&(u.activeCamera=c),r.getProjectionMatrix(!0)},t.ValidateXHRData=function(t,i){void 0===i&&(i=7);try{if(1&i){if(t.responseText&&t.responseText.length>0)return!0;if(1===i)return!1}if(2&i){var r=e.Internals.TGATools.GetTGAHeader(t.response);if(r.width&&r.height&&r.width>0&&r.height>0)return!0;if(2===i)return!1}if(4&i){var n=new Uint8Array(t.response,0,3);return 68===n[0]&&68===n[1]&&83===n[2]}}catch(e){}return!1},t.RandomId=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},Object.defineProperty(t,"NoneLogLevel",{get:function(){return t._NoneLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MessageLogLevel",{get:function(){return t._MessageLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WarningLogLevel",{get:function(){return t._WarningLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ErrorLogLevel",{get:function(){return t._ErrorLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t,"AllLogLevel",{get:function(){return t._MessageLogLevel|t._WarningLogLevel|t._ErrorLogLevel},enumerable:!0,configurable:!0}),t._AddLogEntry=function(e){t._LogCache=e+t._LogCache,t.OnNewCacheEntry&&t.OnNewCacheEntry(e)},t._FormatMessage=function(e){var t=function(e){return e<10?"0"+e:""+e},i=new Date;return"["+t(i.getHours())+":"+t(i.getMinutes())+":"+t(i.getSeconds())+"]: "+e},t._LogDisabled=function(e){},t._LogEnabled=function(e){var i=t._FormatMessage(e);console.log("BJS - "+i);var r="
"+i+"

";t._AddLogEntry(r)},t._WarnDisabled=function(e){},t._WarnEnabled=function(e){var i=t._FormatMessage(e);console.warn("BJS - "+i);var r="
"+i+"

";t._AddLogEntry(r)},t._ErrorDisabled=function(e){},t._ErrorEnabled=function(e){t.errorsCount++;var i=t._FormatMessage(e);console.error("BJS - "+i);var r="
"+i+"

";t._AddLogEntry(r)},Object.defineProperty(t,"LogCache",{get:function(){return t._LogCache},enumerable:!0,configurable:!0}),t.ClearLogCache=function(){t._LogCache="",t.errorsCount=0},Object.defineProperty(t,"LogLevels",{set:function(e){(e&t.MessageLogLevel)===t.MessageLogLevel?t.Log=t._LogEnabled:t.Log=t._LogDisabled,(e&t.WarningLogLevel)===t.WarningLogLevel?t.Warn=t._WarnEnabled:t.Warn=t._WarnDisabled,(e&t.ErrorLogLevel)===t.ErrorLogLevel?t.Error=t._ErrorEnabled:t.Error=t._ErrorDisabled},enumerable:!0,configurable:!0}),t.IsWindowObjectExist=function(){return"undefined"!=typeof window},Object.defineProperty(t,"PerformanceNoneLogLevel",{get:function(){return t._PerformanceNoneLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PerformanceUserMarkLogLevel",{get:function(){return t._PerformanceUserMarkLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PerformanceConsoleLogLevel",{get:function(){return t._PerformanceConsoleLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PerformanceLogLevel",{set:function(e){return(e&t.PerformanceUserMarkLogLevel)===t.PerformanceUserMarkLogLevel?(t.StartPerformanceCounter=t._StartUserMark,void(t.EndPerformanceCounter=t._EndUserMark)):(e&t.PerformanceConsoleLogLevel)===t.PerformanceConsoleLogLevel?(t.StartPerformanceCounter=t._StartPerformanceConsole,void(t.EndPerformanceCounter=t._EndPerformanceConsole)):(t.StartPerformanceCounter=t._StartPerformanceCounterDisabled,void(t.EndPerformanceCounter=t._EndPerformanceCounterDisabled))},enumerable:!0,configurable:!0}),t._StartPerformanceCounterDisabled=function(e,t){},t._EndPerformanceCounterDisabled=function(e,t){},t._StartUserMark=function(e,i){if(void 0===i&&(i=!0),!t._performance){if(!t.IsWindowObjectExist())return;t._performance=window.performance}i&&t._performance.mark&&t._performance.mark(e+"-Begin")},t._EndUserMark=function(e,i){void 0===i&&(i=!0),i&&t._performance.mark&&(t._performance.mark(e+"-End"),t._performance.measure(e,e+"-Begin",e+"-End"))},t._StartPerformanceConsole=function(e,i){void 0===i&&(i=!0),i&&(t._StartUserMark(e,i),console.time&&console.time(e))},t._EndPerformanceConsole=function(e,i){void 0===i&&(i=!0),i&&(t._EndUserMark(e,i),console.time&&console.timeEnd(e))},Object.defineProperty(t,"Now",{get:function(){return t.IsWindowObjectExist()&&window.performance&&window.performance.now?window.performance.now():(new Date).getTime()},enumerable:!0,configurable:!0}),t.GetClassName=function(e,t){void 0===t&&(t=!1);var i=null;if(!t&&e.getClassName)i=e.getClassName();else{if(e instanceof Object){i=(t?e:Object.getPrototypeOf(e)).constructor.__bjsclassName__}i||(i=typeof e)}return i},t.First=function(e,t){for(var i=0,r=e;i=e.length)return null;var r=e.charCodeAt?e.charCodeAt(i):e[i];return r&&r.getHashCode&&(r=r.getHashCode()),"string"==typeof r?t.hashCodeFromStream(t.arrayOrStringFeeder(r)):r}},t.hashCodeFromStream=function(e){for(var t=0,i=0,r=e(i++);null!=r;)t=(t<<5)-t+r,t|=0,r=e(i++);return t},t.BaseUrl="",t.CorsBehavior="anonymous",t.UseFallbackTexture=!0,t.RegisteredExternalClasses={},t.fallbackTexture="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBmRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAAExAAIAAAAQAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQubmV0IDQuMC41AP/bAEMABAIDAwMCBAMDAwQEBAQFCQYFBQUFCwgIBgkNCw0NDQsMDA4QFBEODxMPDAwSGBITFRYXFxcOERkbGRYaFBYXFv/bAEMBBAQEBQUFCgYGChYPDA8WFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFv/AABEIAQABAAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APH6KKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76P//Z",t.PreprocessUrl=function(e){return e},t._NoneLogLevel=0,t._MessageLogLevel=1,t._WarningLogLevel=2,t._ErrorLogLevel=4,t._LogCache="",t.errorsCount=0,t.Log=t._LogEnabled,t.Warn=t._WarnEnabled,t.Error=t._ErrorEnabled,t._PerformanceNoneLogLevel=0,t._PerformanceUserMarkLogLevel=1,t._PerformanceConsoleLogLevel=2,t.StartPerformanceCounter=t._StartPerformanceCounterDisabled,t.EndPerformanceCounter=t._EndPerformanceCounterDisabled,t})();e.Tools=n;var o=(function(){function e(){this._startMonitoringTime=0,this._min=0,this._max=0,this._average=0,this._lastSecAverage=0,this._current=0,this._totalValueCount=0,this._totalAccumulated=0,this._lastSecAccumulated=0,this._lastSecTime=0,this._lastSecValueCount=0}return Object.defineProperty(e.prototype,"min",{get:function(){return this._min},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"max",{get:function(){return this._max},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"average",{get:function(){return this._average},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"lastSecAverage",{get:function(){return this._lastSecAverage},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"current",{get:function(){return this._current},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"total",{get:function(){return this._totalAccumulated},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"count",{get:function(){return this._totalValueCount},enumerable:!0,configurable:!0}),e.prototype.fetchNewFrame=function(){this._totalValueCount++,this._current=0,this._lastSecValueCount++},e.prototype.addCount=function(t,i){e.Enabled&&(this._current+=t,i&&this._fetchResult())},e.prototype.beginMonitoring=function(){e.Enabled&&(this._startMonitoringTime=n.Now)},e.prototype.endMonitoring=function(t){if(void 0===t&&(t=!0),e.Enabled){t&&this.fetchNewFrame();var i=n.Now;this._current=i-this._startMonitoringTime,t&&this._fetchResult()}},e.prototype._fetchResult=function(){this._totalAccumulated+=this._current,this._lastSecAccumulated+=this._current,this._min=Math.min(this._min,this._current),this._max=Math.max(this._max,this._current),this._average=this._totalAccumulated/this._totalValueCount;var e=n.Now;e-this._lastSecTime>1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=e,this._lastSecAccumulated=0,this._lastSecValueCount=0)},e.Enabled=!0,e})();e.PerfCounter=o,e.className=t;var s=(function(){function e(e,t,i,r){void 0===r&&(r=0),this.iterations=e,this._fn=t,this._successCallback=i,this.index=r-1,this._done=!1}return e.prototype.executeNext=function(){this._done||(this.index+1=t)break;if(r(s),o&&o()){e.breakLoop();break}}e.executeNext()}),s)}),n)},e})();e.AsyncLoop=s})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(e){var t=(function(){function e(){this._isAlphaBlendDirty=!1,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this._isBlendConstantsDirty=!1,this._alphaBlend=!1,this._blendFunctionParameters=new Array(4),this._blendEquationParameters=new Array(2),this._blendConstants=new Array(4),this.reset()}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this._isAlphaBlendDirty||this._isBlendFunctionParametersDirty},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"alphaBlend",{get:function(){return this._alphaBlend},set:function(e){this._alphaBlend!==e&&(this._alphaBlend=e,this._isAlphaBlendDirty=!0)},enumerable:!0,configurable:!0}),e.prototype.setAlphaBlendConstants=function(e,t,i,r){this._blendConstants[0]===e&&this._blendConstants[1]===t&&this._blendConstants[2]===i&&this._blendConstants[3]===r||(this._blendConstants[0]=e,this._blendConstants[1]=t,this._blendConstants[2]=i,this._blendConstants[3]=r,this._isBlendConstantsDirty=!0)},e.prototype.setAlphaBlendFunctionParameters=function(e,t,i,r){this._blendFunctionParameters[0]===e&&this._blendFunctionParameters[1]===t&&this._blendFunctionParameters[2]===i&&this._blendFunctionParameters[3]===r||(this._blendFunctionParameters[0]=e,this._blendFunctionParameters[1]=t,this._blendFunctionParameters[2]=i,this._blendFunctionParameters[3]=r,this._isBlendFunctionParametersDirty=!0)},e.prototype.setAlphaEquationParameters=function(e,t){this._blendEquationParameters[0]===e&&this._blendEquationParameters[1]===t||(this._blendEquationParameters[0]=e,this._blendEquationParameters[1]=t,this._isBlendEquationParametersDirty=!0)},e.prototype.reset=function(){this._alphaBlend=!1,this._blendFunctionParameters[0]=null,this._blendFunctionParameters[1]=null,this._blendFunctionParameters[2]=null,this._blendFunctionParameters[3]=null,this._blendEquationParameters[0]=null,this._blendEquationParameters[1]=null,this._blendConstants[0]=null,this._blendConstants[1]=null,this._blendConstants[2]=null,this._blendConstants[3]=null,this._isAlphaBlendDirty=!0,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this._isBlendConstantsDirty=!1},e.prototype.apply=function(e){this.isDirty&&(this._isAlphaBlendDirty&&(this._alphaBlend?e.enable(e.BLEND):e.disable(e.BLEND),this._isAlphaBlendDirty=!1),this._isBlendFunctionParametersDirty&&(e.blendFuncSeparate(this._blendFunctionParameters[0],this._blendFunctionParameters[1],this._blendFunctionParameters[2],this._blendFunctionParameters[3]),this._isBlendFunctionParametersDirty=!1), this._isBlendEquationParametersDirty&&(e.blendEquationSeparate(this._isBlendEquationParametersDirty[0],this._isBlendEquationParametersDirty[1]),this._isBlendEquationParametersDirty=!1),this._isBlendConstantsDirty&&(e.blendColor(this._blendConstants[0],this._blendConstants[1],this._blendConstants[2],this._blendConstants[3]),this._isBlendConstantsDirty=!1))},e})();e._AlphaState=t})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(e){var t=(function(){function e(){this._isDepthTestDirty=!1,this._isDepthMaskDirty=!1,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!1,this.reset()}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this._isDepthFuncDirty||this._isDepthTestDirty||this._isDepthMaskDirty||this._isCullFaceDirty||this._isCullDirty||this._isZOffsetDirty},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"zOffset",{get:function(){return this._zOffset},set:function(e){this._zOffset!==e&&(this._zOffset=e,this._isZOffsetDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cullFace",{get:function(){return this._cullFace},set:function(e){this._cullFace!==e&&(this._cullFace=e,this._isCullFaceDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cull",{get:function(){return this._cull},set:function(e){this._cull!==e&&(this._cull=e,this._isCullDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"depthFunc",{get:function(){return this._depthFunc},set:function(e){this._depthFunc!==e&&(this._depthFunc=e,this._isDepthFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"depthMask",{get:function(){return this._depthMask},set:function(e){this._depthMask!==e&&(this._depthMask=e,this._isDepthMaskDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"depthTest",{get:function(){return this._depthTest},set:function(e){this._depthTest!==e&&(this._depthTest=e,this._isDepthTestDirty=!0)},enumerable:!0,configurable:!0}),e.prototype.reset=function(){this._depthMask=!0,this._depthTest=!0,this._depthFunc=null,this._cullFace=null,this._cull=null,this._zOffset=0,this._isDepthTestDirty=!0,this._isDepthMaskDirty=!0,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!1},e.prototype.apply=function(e){this.isDirty&&(this._isCullDirty&&(this.cull?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this._isCullDirty=!1),this._isCullFaceDirty&&(e.cullFace(this.cullFace),this._isCullFaceDirty=!1),this._isDepthMaskDirty&&(e.depthMask(this.depthMask),this._isDepthMaskDirty=!1),this._isDepthTestDirty&&(this.depthTest?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this._isDepthTestDirty=!1),this._isDepthFuncDirty&&(e.depthFunc(this.depthFunc),this._isDepthFuncDirty=!1),this._isZOffsetDirty&&(this.zOffset?(e.enable(e.POLYGON_OFFSET_FILL),e.polygonOffset(this.zOffset,0)):e.disable(e.POLYGON_OFFSET_FILL),this._isZOffsetDirty=!1))},e})();e._DepthCullingState=t})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var i=(function(){function t(){this._isStencilTestDirty=!1,this._isStencilMaskDirty=!1,this._isStencilFuncDirty=!1,this._isStencilOpDirty=!1,this.reset()}return Object.defineProperty(t.prototype,"isDirty",{get:function(){return this._isStencilTestDirty||this._isStencilMaskDirty||this._isStencilFuncDirty||this._isStencilOpDirty},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilFunc",{get:function(){return this._stencilFunc},set:function(e){this._stencilFunc!==e&&(this._stencilFunc=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilFuncRef",{get:function(){return this._stencilFuncRef},set:function(e){this._stencilFuncRef!==e&&(this._stencilFuncRef=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilFuncMask",{get:function(){return this._stencilFuncMask},set:function(e){this._stencilFuncMask!==e&&(this._stencilFuncMask=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilOpStencilFail",{get:function(){return this._stencilOpStencilFail},set:function(e){this._stencilOpStencilFail!==e&&(this._stencilOpStencilFail=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilOpDepthFail",{get:function(){return this._stencilOpDepthFail},set:function(e){this._stencilOpDepthFail!==e&&(this._stencilOpDepthFail=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilOpStencilDepthPass",{get:function(){return this._stencilOpStencilDepthPass},set:function(e){this._stencilOpStencilDepthPass!==e&&(this._stencilOpStencilDepthPass=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilMask",{get:function(){return this._stencilMask},set:function(e){this._stencilMask!==e&&(this._stencilMask=e,this._isStencilMaskDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilTest",{get:function(){return this._stencilTest},set:function(e){this._stencilTest!==e&&(this._stencilTest=e,this._isStencilTestDirty=!0)},enumerable:!0,configurable:!0}),t.prototype.reset=function(){this._stencilTest=!1,this._stencilMask=255,this._stencilFunc=e.Engine.ALWAYS,this._stencilFuncRef=1,this._stencilFuncMask=255,this._stencilOpStencilFail=e.Engine.KEEP,this._stencilOpDepthFail=e.Engine.KEEP,this._stencilOpStencilDepthPass=e.Engine.REPLACE,this._isStencilTestDirty=!0,this._isStencilMaskDirty=!0,this._isStencilFuncDirty=!0,this._isStencilOpDirty=!0},t.prototype.apply=function(e){this.isDirty&&(this._isStencilTestDirty&&(this.stencilTest?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this._isStencilTestDirty=!1),this._isStencilMaskDirty&&(e.stencilMask(this.stencilMask),this._isStencilMaskDirty=!1),this._isStencilFuncDirty&&(e.stencilFunc(this.stencilFunc,this.stencilFuncRef,this.stencilFuncMask),this._isStencilFuncDirty=!1),this._isStencilOpDirty&&(e.stencilOp(this.stencilOpStencilFail,this.stencilOpDepthFail,this.stencilOpStencilDepthPass),this._isStencilOpDirty=!1))},t})();t._StencilState=i})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=function(e,t,r,n,o){return i(e,o+(n?n+"\n":"")+t,r)},i=function(e,t,i){var r=e.createShader("vertex"===i?e.VERTEX_SHADER:e.FRAGMENT_SHADER);if(e.shaderSource(r,t),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS)){var n=e.getShaderInfoLog(r);if(n)throw new Error(n)}if(!r)throw new Error("Something went wrong while compile the shader.");return r},r=function(t,i,r){var n=r.NEAREST,o=r.NEAREST;switch(t){case e.Texture.BILINEAR_SAMPLINGMODE:n=r.LINEAR,o=i?r.LINEAR_MIPMAP_NEAREST:r.LINEAR;break;case e.Texture.TRILINEAR_SAMPLINGMODE:n=r.LINEAR,o=i?r.LINEAR_MIPMAP_LINEAR:r.LINEAR;break;case e.Texture.NEAREST_SAMPLINGMODE:n=r.NEAREST,o=i?r.NEAREST_MIPMAP_LINEAR:r.NEAREST;break;case e.Texture.NEAREST_NEAREST_MIPNEAREST:n=r.NEAREST,o=i?r.NEAREST_MIPMAP_NEAREST:r.NEAREST;break;case e.Texture.NEAREST_LINEAR_MIPNEAREST:n=r.NEAREST,o=i?r.LINEAR_MIPMAP_NEAREST:r.LINEAR;break;case e.Texture.NEAREST_LINEAR_MIPLINEAR:n=r.NEAREST,o=i?r.LINEAR_MIPMAP_LINEAR:r.LINEAR;break;case e.Texture.NEAREST_LINEAR:n=r.NEAREST,o=r.LINEAR;break;case e.Texture.NEAREST_NEAREST:n=r.NEAREST,o=r.NEAREST;break;case e.Texture.LINEAR_NEAREST_MIPNEAREST:n=r.LINEAR,o=i?r.NEAREST_MIPMAP_NEAREST:r.NEAREST;break;case e.Texture.LINEAR_NEAREST_MIPLINEAR:n=r.LINEAR,o=i?r.NEAREST_MIPMAP_LINEAR:r.NEAREST;break;case e.Texture.LINEAR_LINEAR:n=r.LINEAR,o=r.LINEAR;break;case e.Texture.LINEAR_NEAREST:n=r.LINEAR,o=r.NEAREST}return{min:o,mag:n}},n=function(t,i,r,n,o,s){void 0===s&&(s=null);var a,l=function(){r[i]=a,r._internalCount++,n&&n._removePendingData(a),6===r._internalCount&&o(r)},h=function(e,t){n&&n._removePendingData(a),s&&s(e,t)};a=e.Tools.LoadImage(t,l,h,n?n.database:null),n&&n._addPendingData(a)},o=function(e,t,i,r,o){void 0===o&&(o=null);var s=[];s._internalCount=0;for(var a=0;a<6;a++)n(r[a],a,s,t,i,o)},s=(function(){function e(){}return e})(),a=(function(){function e(){}return e})();e.InstancingAttributeInfo=a;var l=(function(){function e(){}return e})();e.RenderTargetCreationOptions=l;var h=(function(){function e(){}return e})();e.EngineCapabilities=h;var u=(function(){function n(t,i,r,o){void 0===o&&(o=!1);var a=this;this.forcePOTTextures=!1,this.isFullscreen=!1,this.isPointerLock=!1,this.cullBackFaces=!0,this.renderEvenInBackground=!0,this.preventCacheWipeBetweenFrames=!1,this.enableOfflineSupport=!1,this.scenes=new Array,this.postProcesses=new Array,this.onResizeObservable=new e.Observable,this.onCanvasBlurObservable=new e.Observable,this.onCanvasFocusObservable=new e.Observable,this.onCanvasPointerOutObservable=new e.Observable,this.onBeforeTextureInitObservable=new e.Observable,this._vrDisplay=void 0,this._vrSupported=!1,this._vrExclusivePointerMode=!1,this.disableUniformBuffers=!1,this._uniformBuffers=new Array,this.onBeginFrameObservable=new e.Observable,this.onEndFrameObservable=new e.Observable,this.onBeforeShaderCompilationObservable=new e.Observable,this.onAfterShaderCompilationObservable=new e.Observable,this._windowIsBackground=!1,this._webGLVersion=1,this._badOS=!1,this._badDesktopOS=!1,this.onVRDisplayChangedObservable=new e.Observable,this.onVRRequestPresentComplete=new e.Observable,this.onVRRequestPresentStart=new e.Observable,this._colorWrite=!0,this._drawCalls=new e.PerfCounter,this._renderingQueueLaunched=!1,this._activeRenderLoops=new Array,this._deterministicLockstep=!1,this._lockstepMaxSteps=4,this.onContextLostObservable=new e.Observable,this.onContextRestoredObservable=new e.Observable,this._contextWasLost=!1,this._doNotHandleContextLost=!1,this._performanceMonitor=new e.PerformanceMonitor,this._fps=60,this._deltaTime=0,this.disablePerformanceMonitorInBackground=!1,this._depthCullingState=new e.Internals._DepthCullingState,this._stencilState=new e.Internals._StencilState,this._alphaState=new e.Internals._AlphaState,this._alphaMode=n.ALPHA_DISABLE,this._internalTexturesCache=new Array,this._activeTexturesCache={},this._compiledEffects={},this._vertexAttribArraysEnabled=[],this._uintIndicesCurrentlySet=!1,this._currentBoundBuffer=new Array,this._currentBufferPointers=new Array,this._currentInstanceLocations=new Array,this._currentInstanceBuffers=new Array,this._vaoRecordInProgress=!1,this._mustWipeVertexAttributes=!1,this._texturesSupported=new Array,this._onVRFullScreenTriggered=function(){if(a._vrDisplay&&a._vrDisplay.isPresenting){a._oldSize=new e.Size(a.getRenderWidth(),a.getRenderHeight()),a._oldHardwareScaleFactor=a.getHardwareScalingLevel();var t=a._vrDisplay.getEyeParameters("left");a.setHardwareScalingLevel(1),a.setSize(2*t.renderWidth,t.renderHeight)}else a.setHardwareScalingLevel(a._oldHardwareScaleFactor),a.setSize(a._oldSize.width,a._oldSize.height)};var l=null;if(n.Instances.push(this),t){if(r=r||{},t.getContext){if(l=t,this._renderingCanvas=l,null!=i&&(r.antialias=i),void 0===r.deterministicLockstep&&(r.deterministicLockstep=!1),void 0===r.lockstepMaxSteps&&(r.lockstepMaxSteps=4),void 0===r.preserveDrawingBuffer&&(r.preserveDrawingBuffer=!1),void 0===r.audioEngine&&(r.audioEngine=!0),void 0===r.stencil&&(r.stencil=!0),this._deterministicLockstep=r.deterministicLockstep,this._lockstepMaxSteps=r.lockstepMaxSteps,this._doNotHandleContextLost=!!r.doNotHandleContextLost,!r.disableWebGL2Support)try{this._gl=l.getContext("webgl2",r)||l.getContext("experimental-webgl2",r),this._gl&&(this._webGLVersion=2)}catch(e){}if(!this._gl){if(!l)throw new Error("The provided canvas is null or undefined.");try{this._gl=l.getContext("webgl",r)||l.getContext("experimental-webgl",r)}catch(e){throw new Error("WebGL not supported")}}if(!this._gl)throw new Error("WebGL not supported");this._onCanvasFocus=function(){a.onCanvasFocusObservable.notifyObservers(a)},this._onCanvasBlur=function(){a.onCanvasBlurObservable.notifyObservers(a)},l.addEventListener("focus",this._onCanvasFocus),l.addEventListener("blur",this._onCanvasBlur),this._onBlur=function(){a.disablePerformanceMonitorInBackground&&a._performanceMonitor.disable(),a._windowIsBackground=!0},this._onFocus=function(){a.disablePerformanceMonitorInBackground&&a._performanceMonitor.enable(),a._windowIsBackground=!1},this._onCanvasPointerOut=function(){a.onCanvasPointerOutObservable.notifyObservers(a)},window.addEventListener("blur",this._onBlur),window.addEventListener("focus",this._onFocus),l.addEventListener("pointerout",this._onCanvasPointerOut),this._doNotHandleContextLost||(this._onContextLost=function(t){t.preventDefault(),a._contextWasLost=!0,e.Tools.Warn("WebGL context lost."),a.onContextLostObservable.notifyObservers(a)},this._onContextRestored=function(t){setTimeout((function(){a._initGLContext(),a._rebuildEffects(),a._rebuildInternalTextures(),a._rebuildBuffers(),a.wipeCaches(!0),e.Tools.Warn("WebGL context successfully restored."),a.onContextRestoredObservable.notifyObservers(a),a._contextWasLost=!1}),0)},l.addEventListener("webglcontextlost",this._onContextLost,!1),l.addEventListener("webglcontextrestored",this._onContextRestored,!1))}else this._gl=t,this._renderingCanvas=this._gl.canvas,this._gl.renderbufferStorageMultisample&&(this._webGLVersion=2),r.stencil=this._gl.getContextAttributes().stencil;var h=r.limitDeviceRatio||window.devicePixelRatio||1;this._hardwareScalingLevel=o?1/Math.min(h,window.devicePixelRatio||1):1,this.resize(),this._isStencilEnable=!!r.stencil,this._initGLContext(),l&&(this._onFullscreenChange=function(){void 0!==document.fullscreen?a.isFullscreen=document.fullscreen:void 0!==document.mozFullScreen?a.isFullscreen=document.mozFullScreen:void 0!==document.webkitIsFullScreen?a.isFullscreen=document.webkitIsFullScreen:void 0!==document.msIsFullScreen&&(a.isFullscreen=document.msIsFullScreen),a.isFullscreen&&a._pointerLockRequested&&l&&(l.requestPointerLock=l.requestPointerLock||l.msRequestPointerLock||l.mozRequestPointerLock||l.webkitRequestPointerLock,l.requestPointerLock&&l.requestPointerLock())},document.addEventListener("fullscreenchange",this._onFullscreenChange,!1),document.addEventListener("mozfullscreenchange",this._onFullscreenChange,!1),document.addEventListener("webkitfullscreenchange",this._onFullscreenChange,!1),document.addEventListener("msfullscreenchange",this._onFullscreenChange,!1),this._onPointerLockChange=function(){a.isPointerLock=document.mozPointerLockElement===l||document.webkitPointerLockElement===l||document.msPointerLockElement===l||document.pointerLockElement===l},document.addEventListener("pointerlockchange",this._onPointerLockChange,!1),document.addEventListener("mspointerlockchange",this._onPointerLockChange,!1),document.addEventListener("mozpointerlockchange",this._onPointerLockChange,!1),document.addEventListener("webkitpointerlockchange",this._onPointerLockChange,!1),this._onVRDisplayPointerRestricted=function(){l&&l.requestPointerLock()},this._onVRDisplayPointerUnrestricted=function(){document.exitPointerLock()},window.addEventListener("vrdisplaypointerrestricted",this._onVRDisplayPointerRestricted,!1),window.addEventListener("vrdisplaypointerunrestricted",this._onVRDisplayPointerUnrestricted,!1)),r.audioEngine&&e.AudioEngine&&!n.audioEngine&&(n.audioEngine=new e.AudioEngine);for(var u=0;u1&&!this.disableUniformBuffers},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"needPOTTextures",{get:function(){return this._webGLVersion<2||this.forcePOTTextures},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"badOS",{get:function(){return this._badOS},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"badDesktopOS",{get:function(){return this._badDesktopOS},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"performanceMonitor",{get:function(){return this._performanceMonitor},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"texturesSupported",{get:function(){return this._texturesSupported},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"textureFormatInUse",{get:function(){return this._textureFormatInUse},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"currentViewport",{get:function(){return this._cachedViewport},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"emptyTexture",{get:function(){return this._emptyTexture||(this._emptyTexture=this.createRawTexture(new Uint8Array(4),1,1,e.Engine.TEXTUREFORMAT_RGBA,!1,!1,e.Texture.NEAREST_SAMPLINGMODE)),this._emptyTexture},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"emptyTexture3D",{get:function(){return this._emptyTexture3D||(this._emptyTexture3D=this.createRawTexture3D(new Uint8Array(4),1,1,1,e.Engine.TEXTUREFORMAT_RGBA,!1,!1,e.Texture.NEAREST_SAMPLINGMODE)),this._emptyTexture3D},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"emptyCubeTexture",{get:function(){if(!this._emptyCubeTexture){var t=new Uint8Array(4),i=[t,t,t,t,t,t];this._emptyCubeTexture=this.createRawCubeTexture(i,1,e.Engine.TEXTUREFORMAT_RGBA,e.Engine.TEXTURETYPE_UNSIGNED_INT,!1,!1,e.Texture.NEAREST_SAMPLINGMODE)}return this._emptyCubeTexture},enumerable:!0,configurable:!0}),n.prototype._rebuildInternalTextures=function(){for(var e=this._internalTexturesCache.slice(),t=0,i=e;t1||null!==this._gl.getExtension("OES_standard_derivatives"),this._caps.astc=this._gl.getExtension("WEBGL_compressed_texture_astc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_astc"),this._caps.s3tc=this._gl.getExtension("WEBGL_compressed_texture_s3tc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"),this._caps.pvrtc=this._gl.getExtension("WEBGL_compressed_texture_pvrtc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),this._caps.etc1=this._gl.getExtension("WEBGL_compressed_texture_etc1")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"),this._caps.etc2=this._gl.getExtension("WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBGL_compressed_texture_es3_0"),this._caps.textureAnisotropicFilterExtension=this._gl.getExtension("EXT_texture_filter_anisotropic")||this._gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||this._gl.getExtension("MOZ_EXT_texture_filter_anisotropic"),this._caps.maxAnisotropy=this._caps.textureAnisotropicFilterExtension?this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0,this._caps.uintIndices=this._webGLVersion>1||null!==this._gl.getExtension("OES_element_index_uint"),this._caps.fragmentDepthSupported=this._webGLVersion>1||null!==this._gl.getExtension("EXT_frag_depth"),this._caps.highPrecisionShaderSupported=!0,this._caps.timerQuery=this._gl.getExtension("EXT_disjoint_timer_query_webgl2")||this._gl.getExtension("EXT_disjoint_timer_query"),this._caps.timerQuery&&(1===this._webGLVersion&&(this._gl.getQuery=this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery)),this._caps.canUseTimestampForTimerQuery=this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT,this._caps.timerQuery.QUERY_COUNTER_BITS_EXT)>0),this._caps.colorBufferFloat=this._webGLVersion>1&&this._gl.getExtension("EXT_color_buffer_float"),this._caps.textureFloat=this._webGLVersion>1||this._gl.getExtension("OES_texture_float"),this._caps.textureFloatLinearFiltering=this._caps.textureFloat&&this._gl.getExtension("OES_texture_float_linear"),this._caps.textureFloatRender=this._caps.textureFloat&&this._canRenderToFloatFramebuffer(),this._caps.textureHalfFloat=this._webGLVersion>1||this._gl.getExtension("OES_texture_half_float"),this._caps.textureHalfFloatLinearFiltering=this._webGLVersion>1||this._caps.textureHalfFloat&&this._gl.getExtension("OES_texture_half_float_linear"),this._webGLVersion>1&&(this._gl.HALF_FLOAT_OES=5131),this._caps.textureHalfFloatRender=this._caps.textureHalfFloat&&this._canRenderToHalfFloatFramebuffer(),this._caps.textureLOD=this._webGLVersion>1||this._gl.getExtension("EXT_shader_texture_lod"),this._webGLVersion>1)this._caps.drawBuffersExtension=!0;else{var t=this._gl.getExtension("WEBGL_draw_buffers");if(null!==t){this._caps.drawBuffersExtension=!0,this._gl.drawBuffers=t.drawBuffersWEBGL.bind(t),this._gl.DRAW_FRAMEBUFFER=this._gl.FRAMEBUFFER;for(var i=0;i<16;i++)this._gl["COLOR_ATTACHMENT"+i+"_WEBGL"]=t["COLOR_ATTACHMENT"+i+"_WEBGL"]}else this._caps.drawBuffersExtension=!1}if(this._webGLVersion>1)this._caps.depthTextureExtension=!0;else{null!=this._gl.getExtension("WEBGL_depth_texture")&&(this._caps.depthTextureExtension=!0)}if(this._webGLVersion>1)this._caps.vertexArrayObject=!0;else{var r=this._gl.getExtension("OES_vertex_array_object");null!=r?(this._caps.vertexArrayObject=!0,this._gl.createVertexArray=r.createVertexArrayOES.bind(r),this._gl.bindVertexArray=r.bindVertexArrayOES.bind(r),this._gl.deleteVertexArray=r.deleteVertexArrayOES.bind(r)):this._caps.vertexArrayObject=!1}if(this._webGLVersion>1)this._caps.instancedArrays=!0;else{var n=this._gl.getExtension("ANGLE_instanced_arrays");null!=n?(this._caps.instancedArrays=!0,this._gl.drawArraysInstanced=n.drawArraysInstancedANGLE.bind(n),this._gl.drawElementsInstanced=n.drawElementsInstancedANGLE.bind(n),this._gl.vertexAttribDivisor=n.vertexAttribDivisorANGLE.bind(n)):this._caps.instancedArrays=!1}if(this._caps.astc&&this.texturesSupported.push("-astc.ktx"),this._caps.s3tc&&this.texturesSupported.push("-dxt.ktx"),this._caps.pvrtc&&this.texturesSupported.push("-pvrtc.ktx"),this._caps.etc2&&this.texturesSupported.push("-etc2.ktx"),this._caps.etc1&&this.texturesSupported.push("-etc1.ktx"),this._gl.getShaderPrecisionFormat){var o=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);o&&(this._caps.highPrecisionShaderSupported=0!==o.precision)}this.setDepthBuffer(!0),this.setDepthFunctionToLessOrEqual(),this.setDepthWrite(!0)},Object.defineProperty(n.prototype,"webGLVersion",{get:function(){return this._webGLVersion},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isStencilEnable",{get:function(){return this._isStencilEnable},enumerable:!0,configurable:!0}),n.prototype._prepareWorkingCanvas=function(){if(!this._workingCanvas){this._workingCanvas=document.createElement("canvas");var e=this._workingCanvas.getContext("2d");e&&(this._workingContext=e)}},n.prototype.resetTextureCache=function(){for(var e in this._activeTexturesCache)this._activeTexturesCache[e]=null},n.prototype.isDeterministicLockStep=function(){return this._deterministicLockstep},n.prototype.getLockstepMaxSteps=function(){return this._lockstepMaxSteps},n.prototype.getGlInfo=function(){return{vendor:this._glVendor,renderer:this._glRenderer,version:this._glVersion}},n.prototype.getAspectRatio=function(e,t){void 0===t&&(t=!1);var i=e.viewport;return this.getRenderWidth(t)*i.width/(this.getRenderHeight(t)*i.height)},n.prototype.getRenderWidth=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.width:this._gl.drawingBufferWidth},n.prototype.getRenderHeight=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.height:this._gl.drawingBufferHeight},n.prototype.getRenderingCanvas=function(){return this._renderingCanvas},n.prototype.getRenderingCanvasClientRect=function(){return this._renderingCanvas?this._renderingCanvas.getBoundingClientRect():null},n.prototype.setHardwareScalingLevel=function(e){this._hardwareScalingLevel=e,this.resize()},n.prototype.getHardwareScalingLevel=function(){return this._hardwareScalingLevel},n.prototype.getLoadedTexturesCache=function(){return this._internalTexturesCache},n.prototype.getCaps=function(){return this._caps},Object.defineProperty(n.prototype,"drawCalls",{get:function(){return e.Tools.Warn("drawCalls is deprecated. Please use SceneInstrumentation class"),0},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"drawCallsPerfCounter",{get:function(){return e.Tools.Warn("drawCallsPerfCounter is deprecated. Please use SceneInstrumentation class"),null},enumerable:!0, configurable:!0}),n.prototype.getDepthFunction=function(){return this._depthCullingState.depthFunc},n.prototype.setDepthFunction=function(e){this._depthCullingState.depthFunc=e},n.prototype.setDepthFunctionToGreater=function(){this._depthCullingState.depthFunc=this._gl.GREATER},n.prototype.setDepthFunctionToGreaterOrEqual=function(){this._depthCullingState.depthFunc=this._gl.GEQUAL},n.prototype.setDepthFunctionToLess=function(){this._depthCullingState.depthFunc=this._gl.LESS},n.prototype.setDepthFunctionToLessOrEqual=function(){this._depthCullingState.depthFunc=this._gl.LEQUAL},n.prototype.getStencilBuffer=function(){return this._stencilState.stencilTest},n.prototype.setStencilBuffer=function(e){this._stencilState.stencilTest=e},n.prototype.getStencilMask=function(){return this._stencilState.stencilMask},n.prototype.setStencilMask=function(e){this._stencilState.stencilMask=e},n.prototype.getStencilFunction=function(){return this._stencilState.stencilFunc},n.prototype.getStencilFunctionReference=function(){return this._stencilState.stencilFuncRef},n.prototype.getStencilFunctionMask=function(){return this._stencilState.stencilFuncMask},n.prototype.setStencilFunction=function(e){this._stencilState.stencilFunc=e},n.prototype.setStencilFunctionReference=function(e){this._stencilState.stencilFuncRef=e},n.prototype.setStencilFunctionMask=function(e){this._stencilState.stencilFuncMask=e},n.prototype.getStencilOperationFail=function(){return this._stencilState.stencilOpStencilFail},n.prototype.getStencilOperationDepthFail=function(){return this._stencilState.stencilOpDepthFail},n.prototype.getStencilOperationPass=function(){return this._stencilState.stencilOpStencilDepthPass},n.prototype.setStencilOperationFail=function(e){this._stencilState.stencilOpStencilFail=e},n.prototype.setStencilOperationDepthFail=function(e){this._stencilState.stencilOpDepthFail=e},n.prototype.setStencilOperationPass=function(e){this._stencilState.stencilOpStencilDepthPass=e},n.prototype.setDitheringState=function(e){e?this._gl.enable(this._gl.DITHER):this._gl.disable(this._gl.DITHER)},n.prototype.setRasterizerState=function(e){e?this._gl.disable(this._gl.RASTERIZER_DISCARD):this._gl.enable(this._gl.RASTERIZER_DISCARD)},n.prototype.stopRenderLoop=function(e){if(!e)return void(this._activeRenderLoops=[]);var t=this._activeRenderLoops.indexOf(e);t>=0&&this._activeRenderLoops.splice(t,1)},n.prototype._renderLoop=function(){if(!this._contextWasLost){var t=!0;if(!this.renderEvenInBackground&&this._windowIsBackground&&(t=!1),t){this.beginFrame();for(var i=0;i0){var r=null;this._vrDisplay&&this._vrDisplay.isPresenting&&(r=this._vrDisplay),this._frameHandler=e.Tools.QueueNewFrame(this._bindedRenderFunction,r)}else this._renderingQueueLaunched=!1},n.prototype.runRenderLoop=function(t){-1===this._activeRenderLoops.indexOf(t)&&(this._activeRenderLoops.push(t),this._renderingQueueLaunched||(this._renderingQueueLaunched=!0,this._bindedRenderFunction=this._renderLoop.bind(this),this._frameHandler=e.Tools.QueueNewFrame(this._bindedRenderFunction)))},n.prototype.switchFullscreen=function(t){this.isFullscreen?e.Tools.ExitFullscreen():(this._pointerLockRequested=t,this._renderingCanvas&&e.Tools.RequestFullscreen(this._renderingCanvas))},n.prototype.clear=function(e,t,i,r){void 0===r&&(r=!1),this.applyStates();var n=0;t&&e&&(this._gl.clearColor(e.r,e.g,e.b,void 0!==e.a?e.a:1),n|=this._gl.COLOR_BUFFER_BIT),i&&(this._gl.clearDepth(1),n|=this._gl.DEPTH_BUFFER_BIT),r&&(this._gl.clearStencil(0),n|=this._gl.STENCIL_BUFFER_BIT),this._gl.clear(n)},n.prototype.scissorClear=function(e,t,i,r,n){var o=this._gl,s=o.getParameter(o.SCISSOR_TEST),a=o.getParameter(o.SCISSOR_BOX);o.enable(o.SCISSOR_TEST),o.scissor(e,t,i,r),this.clear(n,!0,!0,!0),o.scissor(a[0],a[1],a[2],a[3]),!0===s?o.enable(o.SCISSOR_TEST):o.disable(o.SCISSOR_TEST)},n.prototype.setViewport=function(e,t,i){var r=t||this.getRenderWidth(),n=i||this.getRenderHeight(),o=e.x||0,s=e.y||0;this._cachedViewport=e,this._gl.viewport(o*r,s*n,r*e.width,n*e.height)},n.prototype.setDirectViewport=function(e,t,i,r){var n=this._cachedViewport;return this._cachedViewport=null,this._gl.viewport(e,t,i,r),n},n.prototype.beginFrame=function(){this.onBeginFrameObservable.notifyObservers(this),this._measureFps()},n.prototype.endFrame=function(){this._badOS&&this.flushFramebuffer(),this._vrDisplay&&this._vrDisplay.isPresenting&&this._vrDisplay.submitFrame(),this.onEndFrameObservable.notifyObservers(this)},n.prototype.resize=function(){if(!this._vrDisplay||!this._vrDisplay.isPresenting){var e=this._renderingCanvas?this._renderingCanvas.clientWidth:window.innerWidth,t=this._renderingCanvas?this._renderingCanvas.clientHeight:window.innerHeight;this.setSize(e/this._hardwareScalingLevel,t/this._hardwareScalingLevel)}},n.prototype.setSize=function(e,t){if(this._renderingCanvas&&(this._renderingCanvas.width!==e||this._renderingCanvas.height!==t)){this._renderingCanvas.width=e,this._renderingCanvas.height=t;for(var i=0;i65535){n=!0;break}r=n?new Uint32Array(e):new Uint16Array(e)}else r=new Uint16Array(e);return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,r,t?this._gl.DYNAMIC_DRAW:this._gl.STATIC_DRAW),this._resetIndexBufferBinding(),i.references=1,i.is32Bits=n,i},n.prototype.bindArrayBuffer=function(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.bindBuffer(e,this._gl.ARRAY_BUFFER)},n.prototype.bindUniformBuffer=function(e){this._gl.bindBuffer(this._gl.UNIFORM_BUFFER,e)},n.prototype.bindUniformBufferBase=function(e,t){this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER,t,e)},n.prototype.bindUniformBlock=function(e,t,i){var r=this._gl.getUniformBlockIndex(e,t);this._gl.uniformBlockBinding(e,r,i)},n.prototype.bindIndexBuffer=function(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.bindBuffer(e,this._gl.ELEMENT_ARRAY_BUFFER)},n.prototype.bindBuffer=function(e,t){(this._vaoRecordInProgress||this._currentBoundBuffer[t]!==e)&&(this._gl.bindBuffer(t,e),this._currentBoundBuffer[t]=e)},n.prototype.updateArrayBuffer=function(e){this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,e)},n.prototype.vertexAttribPointer=function(e,t,i,r,n,o,s){var a=this._currentBufferPointers[t],l=!1;a.active?(a.buffer!==e&&(a.buffer=e,l=!0),a.size!==i&&(a.size=i,l=!0),a.type!==r&&(a.type=r,l=!0),a.normalized!==n&&(a.normalized=n,l=!0),a.stride!==o&&(a.stride=o,l=!0),a.offset!==s&&(a.offset=s,l=!0)):(l=!0,a.active=!0,a.index=t,a.size=i,a.type=r,a.normalized=n,a.stride=o,a.offset=s,a.buffer=e),(l||this._vaoRecordInProgress)&&(this.bindArrayBuffer(e),this._gl.vertexAttribPointer(t,i,r,n,o,s))},n.prototype._bindIndexBufferWithCache=function(e){null!=e&&this._cachedIndexBuffer!==e&&(this._cachedIndexBuffer=e,this.bindIndexBuffer(e),this._uintIndicesCurrentlySet=e.is32Bits)},n.prototype._bindVertexBuffersAttributes=function(e,t){var i=t.getAttributesNames();this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.unbindAllAttributes();for(var r=0;r=0){var o=e[i[r]];if(!o)continue;this._gl.enableVertexAttribArray(n),this._vaoRecordInProgress||(this._vertexAttribArraysEnabled[n]=!0);var s=o.getBuffer();s&&(this.vertexAttribPointer(s,n,o.getSize(),this._gl.FLOAT,!1,4*o.getStrideSize(),4*o.getOffset()),o.getIsInstanced()&&(this._gl.vertexAttribDivisor(n,o.getInstanceDivisor()),this._vaoRecordInProgress||(this._currentInstanceLocations.push(n),this._currentInstanceBuffers.push(s))))}}},n.prototype.recordVertexArrayObject=function(e,t,i){var r=this._gl.createVertexArray();return this._vaoRecordInProgress=!0,this._gl.bindVertexArray(r),this._mustWipeVertexAttributes=!0,this._bindVertexBuffersAttributes(e,i),this.bindIndexBuffer(t),this._vaoRecordInProgress=!1,this._gl.bindVertexArray(null),r},n.prototype.bindVertexArrayObject=function(e,t){this._cachedVertexArrayObject!==e&&(this._cachedVertexArrayObject=e,this._gl.bindVertexArray(e),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._uintIndicesCurrentlySet=null!=t&&t.is32Bits,this._mustWipeVertexAttributes=!0)},n.prototype.bindBuffersDirectly=function(e,t,i,r,n){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==n){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=n;var o=n.getAttributesCount();this._unbindVertexArrayObject(),this.unbindAllAttributes();for(var s=0,a=0;a=0&&(this._gl.enableVertexAttribArray(l),this._vertexAttribArraysEnabled[l]=!0,this.vertexAttribPointer(e,l,i[a],this._gl.FLOAT,!1,r,s)),s+=4*i[a]}}this._bindIndexBufferWithCache(t)},n.prototype._unbindVertexArrayObject=function(){this._cachedVertexArrayObject&&(this._cachedVertexArrayObject=null,this._gl.bindVertexArray(null))},n.prototype.bindBuffers=function(e,t,i){this._cachedVertexBuffers===e&&this._cachedEffectForVertexBuffers===i||(this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=i,this._bindVertexBuffersAttributes(e,i)),this._bindIndexBufferWithCache(t)},n.prototype.unbindInstanceAttributes=function(){for(var e,t=0,i=this._currentInstanceLocations.length;t1?"#version 300 es\n":"",a=t(n,e,"vertex",r,s),l=t(n,i,"fragment",r,s),h=this._createShaderProgram(a,l,n,o);return this.onAfterShaderCompilationObservable.notifyObservers(this),h},n.prototype._createShaderProgram=function(e,t,i,r){void 0===r&&(r=null);var n=i.createProgram();if(!n)throw new Error("Unable to create program");if(i.attachShader(n,e),i.attachShader(n,t),this.webGLVersion>1&&r){var o=this.createTransformFeedback();this.bindTransformFeedback(o),this.setTranformFeedbackVaryings(n,r),n.transformFeedback=o}if(i.linkProgram(n),this.webGLVersion>1&&r&&this.bindTransformFeedback(null),!i.getProgramParameter(n,i.LINK_STATUS)){i.validateProgram(n);var s=i.getProgramInfoLog(n);if(s)throw new Error(s)}return i.deleteShader(e),i.deleteShader(t),n},n.prototype.getUniforms=function(e,t){for(var i=new Array,r=0;r0?f.substring(g).toLowerCase():"",y=this.getCaps().s3tc&&".dds"===v,b=".tga"===v,x=!1;!this._textureFormatInUse||_||h||(f=f.substring(0,g)+this._textureFormatInUse,x=!0),n&&n._addPendingData(m),m.url=f,m.generateMipMaps=!i,m.samplingMode=o,m.invertY=r,this._doNotHandleContextLost||(m._buffer=l),s&&m.onLoadedObservable.add(s),h||this._internalTexturesCache.push(m);var T=function(){n&&n._removePendingData(m),x?c.createTexture(t,i,r,n,o,null,a,l,m):(b||y)&&e.Tools.UseFallbackTexture?c.createTexture(e.Tools.fallbackTexture,i,r,n,o,null,a,l,m):a&&a()},A=null;if(x||b||y)x?A=function(t){var s=new e.Internals.KhronosTextureContainer(t,1);c._prepareWebGLTexture(m,n,s.pixelWidth,s.pixelHeight,r,!1,!0,(function(){return s.uploadLevels(c._gl,!i),!1}),o)}:b?A=function(t){var s=new Uint8Array(t),a=e.Internals.TGATools.GetTGAHeader(s);c._prepareWebGLTexture(m,n,a.width,a.height,r,i,!1,(function(){return e.Internals.TGATools.UploadContent(c._gl,s),!1}),o)}:y&&(A=function(t){var s=e.Internals.DDSTools.GetDDSInfo(t),a=(s.isRGB||s.isLuminance||s.mipmapCount>1)&&!i&&s.width>>s.mipmapCount-1==1;c._prepareWebGLTexture(m,n,s.width,s.height,r,!a,s.isFourCC,(function(){return e.Internals.DDSTools.UploadDDSLevels(c,c._gl,t,s,a,1),!1}),o)}),l?A&&A(l):e.Tools.LoadFile(f,(function(e){A&&A(e)}),void 0,n?n.database:void 0,!0,T);else{var E=function(t){p&&!c._doNotHandleContextLost&&(m._buffer=t),c._prepareWebGLTexture(m,n,t.width,t.height,r,i,!1,(function(i,r,o){var s=c._gl,a=t.width===i&&t.height===r,l=u?c._getInternalFormat(u):".jpg"===v?s.RGB:s.RGBA;if(a)return s.texImage2D(s.TEXTURE_2D,0,l,l,s.UNSIGNED_BYTE,t),!1;var h=new e.InternalTexture(c,e.InternalTexture.DATASOURCE_TEMP);return c._bindTextureDirectly(s.TEXTURE_2D,h),s.texImage2D(s.TEXTURE_2D,0,l,l,s.UNSIGNED_BYTE,t),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),c._rescaleTexture(h,m,n,l,(function(){c._releaseTexture(h),c._bindTextureDirectly(s.TEXTURE_2D,m),o()})),!0}),o)};!d||_?l instanceof HTMLImageElement?E(l):e.Tools.LoadImage(f,E,T,n?n.database:null):l instanceof Array||"string"==typeof l||l instanceof ArrayBuffer?e.Tools.LoadImage(l,E,T,n?n.database:null):E(l)}return m},n.prototype._rescaleTexture=function(t,i,r,o,s){var a=this,l=this.createRenderTargetTexture({width:i.width,height:i.height},{generateMipMaps:!1,type:n.TEXTURETYPE_UNSIGNED_INT,samplingMode:e.Texture.BILINEAR_SAMPLINGMODE,generateDepthBuffer:!1,generateStencilBuffer:!1});this._rescalePostProcess||(this._rescalePostProcess=new e.PassPostProcess("rescale",1,null,e.Texture.BILINEAR_SAMPLINGMODE,this,!1,n.TEXTURETYPE_UNSIGNED_INT)),this._rescalePostProcess.getEffect().executeWhenCompiled((function(){a._rescalePostProcess.onApply=function(e){e._bindTexture("textureSampler",t)};var e=r;e||(e=a.scenes[a.scenes.length-1]),e.postProcessManager.directRender([a._rescalePostProcess],l),a._bindTextureDirectly(a._gl.TEXTURE_2D,i),a._gl.copyTexImage2D(a._gl.TEXTURE_2D,0,o,0,0,i.width,i.height,0),a.unBindFramebuffer(l),a._releaseTexture(l),s&&s()}))},n.prototype._getInternalFormat=function(e){var t=this._gl.RGBA;switch(e){case n.TEXTUREFORMAT_ALPHA:t=this._gl.ALPHA;break;case n.TEXTUREFORMAT_LUMINANCE:t=this._gl.LUMINANCE;break;case n.TEXTUREFORMAT_LUMINANCE_ALPHA:t=this._gl.LUMINANCE_ALPHA;break;case n.TEXTUREFORMAT_RGB:t=this._gl.RGB;break;case n.TEXTUREFORMAT_RGBA:t=this._gl.RGBA}return t},n.prototype.updateRawTexture=function(e,t,i,r,n){if(void 0===n&&(n=null),e){var o=this._getInternalFormat(i);this._bindTextureDirectly(this._gl.TEXTURE_2D,e),this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,void 0===r?1:r?1:0),this._doNotHandleContextLost||(e._bufferView=t,e.format=i,e.invertY=r,e._compression=n),e.width%4!=0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),n&&t?this._gl.compressedTexImage2D(this._gl.TEXTURE_2D,0,this.getCaps().s3tc[n],e.width,e.height,0,t):this._gl.texImage2D(this._gl.TEXTURE_2D,0,o,e.width,e.height,0,o,this._gl.UNSIGNED_BYTE,t),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D), this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this.resetTextureCache(),e.isReady=!0}},n.prototype.createRawTexture=function(t,i,n,o,s,a,l,h){void 0===h&&(h=null);var u=new e.InternalTexture(this,e.InternalTexture.DATASOURCE_RAW);u.baseWidth=i,u.baseHeight=n,u.width=i,u.height=n,u.format=o,u.generateMipMaps=s,u.samplingMode=l,u.invertY=a,u._compression=h,this._doNotHandleContextLost||(u._bufferView=t),this.updateRawTexture(u,t,o,a,h),this._bindTextureDirectly(this._gl.TEXTURE_2D,u);var c=r(l,s,this._gl);return this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,c.mag),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,c.min),s&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._internalTexturesCache.push(u),u},n.prototype.createDynamicTexture=function(t,i,r,n){var o=new e.InternalTexture(this,e.InternalTexture.DATASOURCE_DYNAMIC);return o.baseWidth=t,o.baseHeight=i,r&&(t=this.needPOTTextures?e.Tools.GetExponentOfTwo(t,this._caps.maxTextureSize):t,i=this.needPOTTextures?e.Tools.GetExponentOfTwo(i,this._caps.maxTextureSize):i),this.resetTextureCache(),o.width=t,o.height=i,o.isReady=!1,o.generateMipMaps=r,o.samplingMode=n,this.updateTextureSamplingMode(n,o),this._internalTexturesCache.push(o),o},n.prototype.updateTextureSamplingMode=function(e,t){var i=r(e,t.generateMipMaps,this._gl);t.isCube?(this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,t),this._gl.texParameteri(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_MAG_FILTER,i.mag),this._gl.texParameteri(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_MIN_FILTER,i.min),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):t.is3D?(this._bindTextureDirectly(this._gl.TEXTURE_3D,t),this._gl.texParameteri(this._gl.TEXTURE_3D,this._gl.TEXTURE_MAG_FILTER,i.mag),this._gl.texParameteri(this._gl.TEXTURE_3D,this._gl.TEXTURE_MIN_FILTER,i.min),this._bindTextureDirectly(this._gl.TEXTURE_3D,null)):(this._bindTextureDirectly(this._gl.TEXTURE_2D,t),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,i.mag),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,i.min),this._bindTextureDirectly(this._gl.TEXTURE_2D,null)),t.samplingMode=e},n.prototype.updateDynamicTexture=function(e,t,i,r,n){if(void 0===r&&(r=!1),e){this._bindTextureDirectly(this._gl.TEXTURE_2D,e),this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,i?1:0),r&&this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1);var o=n?this._getInternalFormat(n):this._gl.RGBA;this._gl.texImage2D(this._gl.TEXTURE_2D,0,o,o,this._gl.UNSIGNED_BYTE,t),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),r&&this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),this.resetTextureCache(),e.isReady=!0}},n.prototype.updateVideoTexture=function(e,t,i){if(e&&!e._isDisabled){this._bindTextureDirectly(this._gl.TEXTURE_2D,e),this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,i?0:1);try{if(void 0===this._videoTextureSupported&&(this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,t),0!==this._gl.getError()?this._videoTextureSupported=!1:this._videoTextureSupported=!0),this._videoTextureSupported)this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,t);else{if(!e._workingCanvas){e._workingCanvas=document.createElement("canvas");var r=e._workingCanvas.getContext("2d");if(!r)throw new Error("Unable to get 2d context");e._workingContext=r,e._workingCanvas.width=e.width,e._workingCanvas.height=e.height}e._workingContext.drawImage(t,0,0,t.videoWidth,t.videoHeight,0,0,e.width,e.height),this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,e._workingCanvas)}e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this.resetTextureCache(),e.isReady=!0}catch(t){e._isDisabled=!0}}},n.prototype.createRenderTargetTexture=function(t,i){var o=new l;void 0!==i&&"object"==typeof i?(o.generateMipMaps=i.generateMipMaps,o.generateDepthBuffer=void 0===i.generateDepthBuffer||i.generateDepthBuffer,o.generateStencilBuffer=o.generateDepthBuffer&&i.generateStencilBuffer,o.type=void 0===i.type?n.TEXTURETYPE_UNSIGNED_INT:i.type,o.samplingMode=void 0===i.samplingMode?e.Texture.TRILINEAR_SAMPLINGMODE:i.samplingMode):(o.generateMipMaps=i,o.generateDepthBuffer=!0,o.generateStencilBuffer=!1,o.type=n.TEXTURETYPE_UNSIGNED_INT,o.samplingMode=e.Texture.TRILINEAR_SAMPLINGMODE),o.type!==n.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering?o.type!==n.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering||(o.samplingMode=e.Texture.NEAREST_SAMPLINGMODE):o.samplingMode=e.Texture.NEAREST_SAMPLINGMODE;var s=this._gl,a=new e.InternalTexture(this,e.InternalTexture.DATASOURCE_RENDERTARGET);this._bindTextureDirectly(s.TEXTURE_2D,a);var h=t.width||t,u=t.height||t,c=r(o.samplingMode,!!o.generateMipMaps,s);o.type!==n.TEXTURETYPE_FLOAT||this._caps.textureFloat||(o.type=n.TEXTURETYPE_UNSIGNED_INT,e.Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,c.mag),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,c.min),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texImage2D(s.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(o.type),h,u,0,s.RGBA,this._getWebGLTextureType(o.type),null);var f=s.createFramebuffer();return this.bindUnboundFramebuffer(f),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,a._webGLTexture,0),a._depthStencilBuffer=this._setupFramebufferDepthAttachments(!!o.generateStencilBuffer,o.generateDepthBuffer,h,u),o.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(s.TEXTURE_2D,null),s.bindRenderbuffer(s.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),a._framebuffer=f,a.baseWidth=h,a.baseHeight=u,a.width=h,a.height=u,a.isReady=!0,a.samples=1,a.generateMipMaps=!!o.generateMipMaps,a.samplingMode=o.samplingMode,a.type=o.type,a._generateDepthBuffer=o.generateDepthBuffer,a._generateStencilBuffer=!!o.generateStencilBuffer,this.resetTextureCache(),this._internalTexturesCache.push(a),a},n.prototype.createMultipleRenderTarget=function(t,i){var o=!1,s=!0,a=!1,l=!1,h=1,u=n.TEXTURETYPE_UNSIGNED_INT,c=e.Texture.TRILINEAR_SAMPLINGMODE,f=[],d=[];void 0!==i&&(o=i.generateMipMaps,s=void 0===i.generateDepthBuffer||i.generateDepthBuffer,a=i.generateStencilBuffer,l=i.generateDepthTexture,h=i.textureCount||1,i.types&&(f=i.types),i.samplingModes&&(d=i.samplingModes));var p=this._gl,_=p.createFramebuffer();this.bindUnboundFramebuffer(_);for(var m=t.width||t,g=t.height||t,v=[],y=[],b=this._setupFramebufferDepthAttachments(a,s,m,g),x=0;x1?"COLOR_ATTACHMENT"+x:"COLOR_ATTACHMENT"+x+"_WEBGL"];v.push(P),y.push(M),p.activeTexture(p["TEXTURE"+x]),p.bindTexture(p.TEXTURE_2D,P._webGLTexture),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,E.mag),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,E.min),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE),p.texImage2D(p.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(A),m,g,0,p.RGBA,this._getWebGLTextureType(A),null),p.framebufferTexture2D(p.DRAW_FRAMEBUFFER,M,p.TEXTURE_2D,P._webGLTexture,0),o&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(p.TEXTURE_2D,null),P._framebuffer=_,P._depthStencilBuffer=b,P.baseWidth=m,P.baseHeight=g,P.width=m,P.height=g,P.isReady=!0,P.samples=1,P.generateMipMaps=o,P.samplingMode=T,P.type=A,P._generateDepthBuffer=s,P._generateStencilBuffer=a,this._internalTexturesCache.push(P)}if(l&&this._caps.depthTextureExtension){var S=new e.InternalTexture(this,e.InternalTexture.DATASOURCE_MULTIRENDERTARGET);p.activeTexture(p.TEXTURE0),p.bindTexture(p.TEXTURE_2D,S._webGLTexture),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.NEAREST),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.NEAREST),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE),p.texImage2D(p.TEXTURE_2D,0,this.webGLVersion<2?p.DEPTH_COMPONENT:p.DEPTH_COMPONENT16,m,g,0,p.DEPTH_COMPONENT,p.UNSIGNED_SHORT,null),p.framebufferTexture2D(p.FRAMEBUFFER,p.DEPTH_ATTACHMENT,p.TEXTURE_2D,S._webGLTexture,0),S._framebuffer=_,S.baseWidth=m,S.baseHeight=g,S.width=m,S.height=g,S.isReady=!0,S.samples=1,S.generateMipMaps=o,S.samplingMode=p.NEAREST,S._generateDepthBuffer=s,S._generateStencilBuffer=a,v.push(S),this._internalTexturesCache.push(S)}return p.drawBuffers(y),p.bindRenderbuffer(p.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),this.resetTextureCache(),v},n.prototype._setupFramebufferDepthAttachments=function(e,t,i,r,n){void 0===n&&(n=1);var o=null,s=this._gl;return e?(o=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,o),n>1?s.renderbufferStorageMultisample(s.RENDERBUFFER,n,s.DEPTH24_STENCIL8,i,r):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_STENCIL,i,r),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,o)):t&&(o=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,o),n>1?s.renderbufferStorageMultisample(s.RENDERBUFFER,n,s.DEPTH_COMPONENT16,i,r):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_COMPONENT16,i,r),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.RENDERBUFFER,o)),o},n.prototype.updateRenderTargetTextureSampleCount=function(e,t){if(this.webGLVersion<2||!e)return 1;if(e.samples===t)return t;var i=this._gl;if(t=Math.min(t,i.getParameter(i.MAX_SAMPLES)),e._depthStencilBuffer&&i.deleteRenderbuffer(e._depthStencilBuffer),e._MSAAFramebuffer&&i.deleteFramebuffer(e._MSAAFramebuffer),e._MSAARenderBuffer&&i.deleteRenderbuffer(e._MSAARenderBuffer),t>1){var r=i.createFramebuffer();if(!r)throw new Error("Unable to create multi sampled framebuffer");e._MSAAFramebuffer=r,this.bindUnboundFramebuffer(e._MSAAFramebuffer);var n=i.createRenderbuffer();if(!n)throw new Error("Unable to create multi sampled framebuffer");i.bindRenderbuffer(i.RENDERBUFFER,n),i.renderbufferStorageMultisample(i.RENDERBUFFER,t,i.RGBA8,e.width,e.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,n),e._MSAARenderBuffer=n}else this.bindUnboundFramebuffer(e._framebuffer);return e.samples=t,e._depthStencilBuffer=this._setupFramebufferDepthAttachments(e._generateStencilBuffer,e._generateDepthBuffer,e.width,e.height,t),i.bindRenderbuffer(i.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),t},n.prototype._uploadDataToTexture=function(e,t,i,r,n,o,s,a){this._gl.texImage2D(e,t,i,r,n,0,o,s,a)},n.prototype._uploadCompressedDataToTexture=function(e,t,i,r,n,o){this._gl.compressedTexImage2D(e,t,i,r,n,0,o)},n.prototype.createRenderTargetCubeTexture=function(t,i){var n=this._gl,o=new e.InternalTexture(this,e.InternalTexture.DATASOURCE_RENDERTARGET),s=!0,a=!0,l=!1,h=e.Texture.TRILINEAR_SAMPLINGMODE;void 0!==i&&(s=void 0===i.generateMipMaps||i.generateMipMaps,a=void 0===i.generateDepthBuffer||i.generateDepthBuffer,l=!(!a||!i.generateStencilBuffer),void 0!==i.samplingMode&&(h=i.samplingMode)),o.isCube=!0,o.generateMipMaps=s,o.samples=1,o.samplingMode=h;var u=r(h,s,n);this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,o);for(var c=0;c<6;c++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,n.RGBA,t,t,0,n.RGBA,n.UNSIGNED_BYTE,null);n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MAG_FILTER,u.mag),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MIN_FILTER,u.min),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE);var f=n.createFramebuffer();return this.bindUnboundFramebuffer(f),o._depthStencilBuffer=this._setupFramebufferDepthAttachments(l,a,t,t),o.generateMipMaps&&(this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,o),n.generateMipmap(n.TEXTURE_CUBE_MAP)),this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,null),n.bindRenderbuffer(n.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),o._framebuffer=f,o.width=t,o.height=t,o.isReady=!0,this.resetTextureCache(),this._internalTexturesCache.push(o),o},n.prototype.createPrefilteredCubeTexture=function(t,i,r,n,o,s,a,l){var h=this;void 0===o&&(o=null),void 0===s&&(s=null),void 0===l&&(l=null);var u=function(t){if(!t)return void(o&&o(null));var s=t.texture;if(s._dataSource=e.InternalTexture.DATASOURCE_CUBEPREFILTERED,s._lodGenerationScale=r,s._lodGenerationOffset=n,h._caps.textureLOD)return void(o&&o(s));var a=h._gl,l=t.width;if(l){for(var u=[],c=0;c<3;c++){var f=c/2,d=1-f,p=n,_=e.Scalar.Log2(l)*r+n,m=p+(_-p)*d,g=Math.round(Math.min(Math.max(m,0),_)),v=new e.InternalTexture(h,e.InternalTexture.DATASOURCE_TEMP);if(v.isCube=!0,h._bindTextureDirectly(a.TEXTURE_CUBE_MAP,v),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),t.isDDS){var y=t.info,b=t.data;a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,y.isCompressed?1:0),e.Internals.DDSTools.UploadDDSLevels(h,h._gl,b,y,!0,6,g)}else e.Tools.Warn("DDS is the only prefiltered cube map supported so far.");h._bindTextureDirectly(a.TEXTURE_CUBE_MAP,null);var x=new e.BaseTexture(i);x.isCube=!0,x._texture=v,v.isReady=!0,u.push(x)}s._lodTextureHigh=u[2],s._lodTextureMid=u[1],s._lodTextureLow=u[0],o&&o(s)}};return this.createCubeTexture(t,i,null,!1,u,s,a,l)},n.prototype.createCubeTexture=function(t,i,r,n,s,a,l,h){var u=this;void 0===s&&(s=null),void 0===a&&(a=null),void 0===h&&(h=null);var c=this._gl,f=new e.InternalTexture(this,e.InternalTexture.DATASOURCE_CUBE);f.isCube=!0,f.url=t,f.generateMipMaps=!n,this._doNotHandleContextLost||(f._extension=h,f._files=r);var d=!1,p=!1,_=t.lastIndexOf("."),m=h||(_>-1?t.substring(_).toLowerCase():"");this._textureFormatInUse?(m=this._textureFormatInUse,t=(_>-1?t.substring(0,_):t)+this._textureFormatInUse,d=!0):p=".dds"===m;var g=function(e,t){a&&a(e.status+" "+e.statusText,t)};if(d)e.Tools.LoadFile(t,(function(t){var i=new e.Internals.KhronosTextureContainer(t,6),r=i.numberOfMipmapLevels>1&&!n;u._bindTextureDirectly(c.TEXTURE_CUBE_MAP,f),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,1),i.uploadLevels(u._gl,!n),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,r?c.LINEAR_MIPMAP_LINEAR:c.LINEAR),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),u._bindTextureDirectly(c.TEXTURE_CUBE_MAP,null),u.resetTextureCache(),f.width=i.pixelWidth,f.height=i.pixelHeight,f.isReady=!0}),void 0,void 0,!0,g);else if(p)e.Tools.LoadFile(t,(function(t){var i=e.Internals.DDSTools.GetDDSInfo(t),r=(i.isRGB||i.isLuminance||i.mipmapCount>1)&&!n;u._bindTextureDirectly(c.TEXTURE_CUBE_MAP,f),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,i.isCompressed?1:0),e.Internals.DDSTools.UploadDDSLevels(u,u._gl,t,i,r,6),n||i.isFourCC||1!==i.mipmapCount||c.generateMipmap(c.TEXTURE_CUBE_MAP),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,r?c.LINEAR_MIPMAP_LINEAR:c.LINEAR),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),u._bindTextureDirectly(c.TEXTURE_CUBE_MAP,null),u.resetTextureCache(),f.width=i.width,f.height=i.height,f.isReady=!0,f.type=i.textureType,s&&s({isDDS:!0,width:i.width,info:i,data:t,texture:f})}),void 0,void 0,!0,g);else{if(!r)throw new Error("Cannot load cubemap because files were not defined");o(0,i,(function(t){var i=u.needPOTTextures?e.Tools.GetExponentOfTwo(t[0].width,u._caps.maxCubemapTextureSize):t[0].width,r=i;if(u._prepareWorkingCanvas(),u._workingCanvas&&u._workingContext){u._workingCanvas.width=i,u._workingCanvas.height=r;var o=[c.TEXTURE_CUBE_MAP_POSITIVE_X,c.TEXTURE_CUBE_MAP_POSITIVE_Y,c.TEXTURE_CUBE_MAP_POSITIVE_Z,c.TEXTURE_CUBE_MAP_NEGATIVE_X,c.TEXTURE_CUBE_MAP_NEGATIVE_Y,c.TEXTURE_CUBE_MAP_NEGATIVE_Z];u._bindTextureDirectly(c.TEXTURE_CUBE_MAP,f),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,0);for(var a=l?u._getInternalFormat(l):u._gl.RGBA,h=0;h>y,x=0;x<6;x++){var T=v[y][x];g&&(T=d._convertRGBtoRGBATextureData(T,b,b,o)),p.texImage2D(x,y,m,b,b,0,c,u,T)}d._bindTextureDirectly(p.TEXTURE_CUBE_MAP,null)}else _.generateMipMaps=!s,d.updateRawCubeTexture(_,r,n,o,f);_.isReady=!0,d.resetTextureCache(),i._removePendingData(_),h&&h()}};return e.Tools.LoadFile(t,(function(e){g(e)}),void 0,i.database,!0,m),_},n.prototype.updateRawTexture3D=function(e,t,i,r,n){void 0===n&&(n=null);var o=this._getInternalFormat(i);this._bindTextureDirectly(this._gl.TEXTURE_3D,e),this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,void 0===r?1:r?1:0),this._doNotHandleContextLost||(e._bufferView=t,e.format=i,e.invertY=r,e._compression=n),e.width%4!=0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),n&&t?this._gl.compressedTexImage3D(this._gl.TEXTURE_3D,0,this.getCaps().s3tc[n],e.width,e.height,e.depth,0,t):this._gl.texImage3D(this._gl.TEXTURE_3D,0,o,e.width,e.height,e.depth,0,o,this._gl.UNSIGNED_BYTE,t),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_3D),this._bindTextureDirectly(this._gl.TEXTURE_3D,null),this.resetTextureCache(),e.isReady=!0},n.prototype.createRawTexture3D=function(t,i,n,o,s,a,l,h,u){void 0===u&&(u=null);var c=new e.InternalTexture(this,e.InternalTexture.DATASOURCE_RAW3D);c.baseWidth=i,c.baseHeight=n,c.baseDepth=o,c.width=i,c.height=n,c.depth=o,c.format=s,c.generateMipMaps=a,c.samplingMode=h,c.is3D=!0,this._doNotHandleContextLost||(c._bufferView=t),this.updateRawTexture3D(c,t,s,l,u),this._bindTextureDirectly(this._gl.TEXTURE_3D,c);var f=r(h,a,this._gl);return this._gl.texParameteri(this._gl.TEXTURE_3D,this._gl.TEXTURE_MAG_FILTER,f.mag),this._gl.texParameteri(this._gl.TEXTURE_3D,this._gl.TEXTURE_MIN_FILTER,f.min),a&&this._gl.generateMipmap(this._gl.TEXTURE_3D),this._bindTextureDirectly(this._gl.TEXTURE_3D,null),this._internalTexturesCache.push(c),c},n.prototype._prepareWebGLTextureContinuation=function(e,t,i,n,o){var s=this._gl;if(s){var a=r(o,!i,s);s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,a.mag),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,a.min),i||n||s.generateMipmap(s.TEXTURE_2D),this._bindTextureDirectly(s.TEXTURE_2D,null),this.resetTextureCache(),t&&t._removePendingData(e),e.onLoadedObservable.notifyObservers(e),e.onLoadedObservable.clear()}},n.prototype._prepareWebGLTexture=function(t,i,r,n,o,s,a,l,h){var u=this;void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE);var c=this.needPOTTextures?e.Tools.GetExponentOfTwo(r,this.getCaps().maxTextureSize):r,f=this.needPOTTextures?e.Tools.GetExponentOfTwo(n,this.getCaps().maxTextureSize):n,d=this._gl;if(d){if(!t._webGLTexture)return this.resetTextureCache(),void(i&&i._removePendingData(t));this._bindTextureDirectly(d.TEXTURE_2D,t),d.pixelStorei(d.UNPACK_FLIP_Y_WEBGL,void 0===o?1:o?1:0),t.baseWidth=r,t.baseHeight=n,t.width=c,t.height=f,t.isReady=!0,l(c,f,(function(){u._prepareWebGLTextureContinuation(t,i,s,a,h)}))||this._prepareWebGLTextureContinuation(t,i,s,a,h)}},n.prototype._convertRGBtoRGBATextureData=function(e,t,i,r){var o;o=r===n.TEXTURETYPE_FLOAT?new Float32Array(t*i*4):new Uint32Array(t*i*4);for(var s=0;s1&&this._bindTextureDirectly(this._gl.TEXTURE_3D,null)},n.prototype.setTexture=function(e,t,i){e<0||this._setTexture(e,i)&&this._gl.uniform1i(t,e)},n.prototype._setTexture=function(t,i){if(!i)return null!=this._activeTexturesCache[t]&&(this.activateTextureChannel(this._gl.TEXTURE0+t),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),this.webGLVersion>1&&this._bindTextureDirectly(this._gl.TEXTURE_3D,null)),!1;var r=!1;if(i.video)this.activateTextureChannel(this._gl.TEXTURE0+t),r=!0,i.update();else if(i.delayLoadState===n.DELAYLOADSTATE_NOTLOADED)return i.delayLoad(),!1;var o;if(o=i.isReady()?i.getInternalTexture():i.isCube?this.emptyCubeTexture:i.is3D?this.emptyTexture3D:this.emptyTexture,r||this.activateTextureChannel(this._gl.TEXTURE0+t),this._activeTexturesCache[this._activeTextureChannel]===o)return!1;if(o&&o.is3D){if(this._bindTextureDirectly(this._gl.TEXTURE_3D,o),o&&o._cachedWrapU!==i.wrapU)switch(o._cachedWrapU=i.wrapU,i.wrapU){case e.Texture.WRAP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_3D,this._gl.TEXTURE_WRAP_S,this._gl.REPEAT);break;case e.Texture.CLAMP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_3D,this._gl.TEXTURE_WRAP_S,this._gl.CLAMP_TO_EDGE);break;case e.Texture.MIRROR_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_3D,this._gl.TEXTURE_WRAP_S,this._gl.MIRRORED_REPEAT)}if(o&&o._cachedWrapV!==i.wrapV)switch(o._cachedWrapV=i.wrapV,i.wrapV){case e.Texture.WRAP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_3D,this._gl.TEXTURE_WRAP_T,this._gl.REPEAT);break;case e.Texture.CLAMP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_3D,this._gl.TEXTURE_WRAP_T,this._gl.CLAMP_TO_EDGE);break;case e.Texture.MIRROR_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_3D,this._gl.TEXTURE_WRAP_T,this._gl.MIRRORED_REPEAT)}if(o&&o._cachedWrapR!==i.wrapR)switch(o._cachedWrapR=i.wrapR,i.wrapV){case e.Texture.WRAP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_3D,this._gl.TEXTURE_WRAP_R,this._gl.REPEAT);break;case e.Texture.CLAMP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_3D,this._gl.TEXTURE_WRAP_R,this._gl.CLAMP_TO_EDGE);break;case e.Texture.MIRROR_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_3D,this._gl.TEXTURE_WRAP_R,this._gl.MIRRORED_REPEAT)}this._setAnisotropicLevel(this._gl.TEXTURE_3D,i)}else if(o&&o.isCube){if(this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,o),o._cachedCoordinatesMode!==i.coordinatesMode){o._cachedCoordinatesMode=i.coordinatesMode;var s=i.coordinatesMode!==e.Texture.CUBIC_MODE&&i.coordinatesMode!==e.Texture.SKYBOX_MODE?this._gl.REPEAT:this._gl.CLAMP_TO_EDGE;this._gl.texParameteri(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_WRAP_S,s),this._gl.texParameteri(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_WRAP_T,s)}this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP,i)}else{if(this._bindTextureDirectly(this._gl.TEXTURE_2D,o),o&&o._cachedWrapU!==i.wrapU)switch(o._cachedWrapU=i.wrapU,i.wrapU){case e.Texture.WRAP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.REPEAT);break;case e.Texture.CLAMP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.CLAMP_TO_EDGE);break;case e.Texture.MIRROR_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.MIRRORED_REPEAT)}if(o&&o._cachedWrapV!==i.wrapV)switch(o._cachedWrapV=i.wrapV,i.wrapV){case e.Texture.WRAP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.REPEAT);break;case e.Texture.CLAMP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.CLAMP_TO_EDGE);break;case e.Texture.MIRROR_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.MIRRORED_REPEAT)}this._setAnisotropicLevel(this._gl.TEXTURE_2D,i)}return!0},n.prototype.setTextureArray=function(e,t,i){if(!(e<0)&&t){this._textureUnits&&this._textureUnits.length===i.length||(this._textureUnits=new Int32Array(i.length));for(var r=0;r=this._caps.maxVertexAttribs||!this._vertexAttribArraysEnabled[e]||(this._gl.disableVertexAttribArray(e),this._vertexAttribArraysEnabled[e]=!1,this._currentBufferPointers[e].active=!1)},n.prototype.releaseEffects=function(){for(var e in this._compiledEffects)this._deleteProgram(this._compiledEffects[e]._program);this._compiledEffects={}}, n.prototype.dispose=function(){for(this.hideLoadingUI(),this.stopRenderLoop();this.postProcesses.length;)this.postProcesses[0].dispose();for(this._emptyTexture&&(this._releaseTexture(this._emptyTexture),this._emptyTexture=null),this._emptyCubeTexture&&(this._releaseTexture(this._emptyCubeTexture),this._emptyCubeTexture=null),this._rescalePostProcess&&this._rescalePostProcess.dispose();this.scenes.length;)this.scenes[0].dispose();n.audioEngine&&n.audioEngine.dispose(),this.releaseEffects(),this.unbindAllAttributes(),this._dummyFramebuffer&&this._gl.deleteFramebuffer(this._dummyFramebuffer),this.disableVR(),e.Tools.IsWindowObjectExist()&&(window.removeEventListener("blur",this._onBlur),window.removeEventListener("focus",this._onFocus),window.removeEventListener("vrdisplaypointerrestricted",this._onVRDisplayPointerRestricted),window.removeEventListener("vrdisplaypointerunrestricted",this._onVRDisplayPointerUnrestricted),this._renderingCanvas&&(this._renderingCanvas.removeEventListener("focus",this._onCanvasFocus),this._renderingCanvas.removeEventListener("blur",this._onCanvasBlur),this._renderingCanvas.removeEventListener("pointerout",this._onCanvasBlur),this._doNotHandleContextLost||(this._renderingCanvas.removeEventListener("webglcontextlost",this._onContextLost),this._renderingCanvas.removeEventListener("webglcontextrestored",this._onContextRestored))),document.removeEventListener("fullscreenchange",this._onFullscreenChange),document.removeEventListener("mozfullscreenchange",this._onFullscreenChange),document.removeEventListener("webkitfullscreenchange",this._onFullscreenChange),document.removeEventListener("msfullscreenchange",this._onFullscreenChange),document.removeEventListener("pointerlockchange",this._onPointerLockChange),document.removeEventListener("mspointerlockchange",this._onPointerLockChange),document.removeEventListener("mozpointerlockchange",this._onPointerLockChange),document.removeEventListener("webkitpointerlockchange",this._onPointerLockChange),this._onVrDisplayConnect&&(window.removeEventListener("vrdisplayconnect",this._onVrDisplayConnect),this._onVrDisplayDisconnect&&window.removeEventListener("vrdisplaydisconnect",this._onVrDisplayDisconnect),this._onVrDisplayPresentChange&&window.removeEventListener("vrdisplaypresentchange",this._onVrDisplayPresentChange),this._onVrDisplayConnect=null,this._onVrDisplayDisconnect=null));var t=n.Instances.indexOf(this);t>=0&&n.Instances.splice(t,1),this._workingCanvas=null,this._workingContext=null,this._currentBufferPointers=[],this._renderingCanvas=null,this._currentProgram=null,this.onResizeObservable.clear(),this.onCanvasBlurObservable.clear(),this.onCanvasFocusObservable.clear(),this.onCanvasPointerOutObservable.clear(),this.onBeginFrameObservable.clear(),this.onEndFrameObservable.clear(),e.Effect.ResetCache()},n.prototype.displayLoadingUI=function(){if(e.Tools.IsWindowObjectExist()){var t=this.loadingScreen;t&&t.displayLoadingUI()}},n.prototype.hideLoadingUI=function(){if(e.Tools.IsWindowObjectExist()){var t=this.loadingScreen;t&&t.hideLoadingUI()}},Object.defineProperty(n.prototype,"loadingScreen",{get:function(){return!this._loadingScreen&&e.DefaultLoadingScreen&&this._renderingCanvas&&(this._loadingScreen=new e.DefaultLoadingScreen(this._renderingCanvas)),this._loadingScreen},set:function(e){this._loadingScreen=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"loadingUIText",{set:function(e){this.loadingScreen.loadingUIText=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"loadingUIBackgroundColor",{set:function(e){this.loadingScreen.loadingUIBackgroundColor=e},enumerable:!0,configurable:!0}),n.prototype.attachContextLostEvent=function(e){this._renderingCanvas&&this._renderingCanvas.addEventListener("webglcontextlost",e,!1)},n.prototype.attachContextRestoredEvent=function(e){this._renderingCanvas&&this._renderingCanvas.addEventListener("webglcontextrestored",e,!1)},n.prototype.getVertexShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return t?this._gl.getShaderSource(t[0]):null},n.prototype.getFragmentShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return t?this._gl.getShaderSource(t[1]):null},n.prototype.getError=function(){return this._gl.getError()},n.prototype.getFps=function(){return this._fps},n.prototype.getDeltaTime=function(){return this._deltaTime},n.prototype._measureFps=function(){this._performanceMonitor.sampleFrame(),this._fps=this._performanceMonitor.averageFPS,this._deltaTime=this._performanceMonitor.instantaneousFrameTime||0},n.prototype._readTexturePixels=function(e,t,i,r){void 0===r&&(r=-1);var n=this._gl;if(!this._dummyFramebuffer){var o=n.createFramebuffer();if(!o)throw new Error("Unable to create dummy framebuffer");this._dummyFramebuffer=o}n.bindFramebuffer(n.FRAMEBUFFER,this._dummyFramebuffer),r>-1?n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+r,e._webGLTexture,0):n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,e._webGLTexture,0);var s,a=void 0!==e.type?this._getWebGLTextureType(e.type):n.UNSIGNED_BYTE;switch(a){case n.UNSIGNED_BYTE:s=new Uint8Array(4*t*i),a=n.UNSIGNED_BYTE;break;default:s=new Float32Array(4*t*i),a=n.FLOAT}return n.readPixels(0,0,t,i,n.RGBA,a,s),n.bindFramebuffer(n.FRAMEBUFFER,this._currentFramebuffer),s},n.prototype._canRenderToFloatFramebuffer=function(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(e.Engine.TEXTURETYPE_FLOAT)},n.prototype._canRenderToHalfFloatFramebuffer=function(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(e.Engine.TEXTURETYPE_HALF_FLOAT)},n.prototype._canRenderToFramebuffer=function(e){for(var t=this._gl;t.getError()!==t.NO_ERROR;);var i=!0,r=t.createTexture();t.bindTexture(t.TEXTURE_2D,r),t.texImage2D(t.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(e),1,1,0,t.RGBA,this._getWebGLTextureType(e),null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST);var n=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,n),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r,0);var o=t.checkFramebufferStatus(t.FRAMEBUFFER);if(i=i&&o===t.FRAMEBUFFER_COMPLETE,i=i&&t.getError()===t.NO_ERROR,i&&(t.clear(t.COLOR_BUFFER_BIT),i=i&&t.getError()===t.NO_ERROR),i){t.bindFramebuffer(t.FRAMEBUFFER,null);var s=t.RGBA,a=t.UNSIGNED_BYTE,l=new Uint8Array(4);t.readPixels(0,0,1,1,s,a,l),i=i&&t.getError()===t.NO_ERROR}for(t.deleteTexture(r),t.deleteFramebuffer(n),t.bindFramebuffer(t.FRAMEBUFFER,null);!i&&t.getError()!==t.NO_ERROR;);return i},n.prototype._getWebGLTextureType=function(e){return e===n.TEXTURETYPE_FLOAT?this._gl.FLOAT:e===n.TEXTURETYPE_HALF_FLOAT?this._gl.HALF_FLOAT_OES:this._gl.UNSIGNED_BYTE},n.prototype._getRGBABufferInternalSizedFormat=function(e){return 1===this._webGLVersion?this._gl.RGBA:e===n.TEXTURETYPE_FLOAT?this._gl.RGBA32F:e===n.TEXTURETYPE_HALF_FLOAT?this._gl.RGBA16F:this._gl.RGBA},n.prototype.createQuery=function(){return this._gl.createQuery()},n.prototype.deleteQuery=function(e){return this._gl.deleteQuery(e),this},n.prototype.isQueryResultAvailable=function(e){return this._gl.getQueryParameter(e,this._gl.QUERY_RESULT_AVAILABLE)},n.prototype.getQueryResult=function(e){return this._gl.getQueryParameter(e,this._gl.QUERY_RESULT)},n.prototype.beginOcclusionQuery=function(e,t){var i=this.getGlAlgorithmType(e);return this._gl.beginQuery(i,t),this},n.prototype.endOcclusionQuery=function(e){var t=this.getGlAlgorithmType(e);return this._gl.endQuery(t),this},n.prototype._createTimeQuery=function(){var e=this._caps.timerQuery;return e.createQueryEXT?e.createQueryEXT():this.createQuery()},n.prototype._deleteTimeQuery=function(e){var t=this._caps.timerQuery;if(t.deleteQueryEXT)return void t.deleteQueryEXT(e);this.deleteQuery(e)},n.prototype._getTimeQueryResult=function(e){var t=this._caps.timerQuery;return t.getQueryObjectEXT?t.getQueryObjectEXT(e,t.QUERY_RESULT_EXT):this.getQueryResult(e)},n.prototype._getTimeQueryAvailability=function(e){var t=this._caps.timerQuery;return t.getQueryObjectEXT?t.getQueryObjectEXT(e,t.QUERY_RESULT_AVAILABLE_EXT):this.isQueryResultAvailable(e)},n.prototype.startTimeQuery=function(){var t=this._caps.timerQuery;if(!t)return null;var i=new e._TimeToken;if(this._gl.getParameter(t.GPU_DISJOINT_EXT),this._caps.canUseTimestampForTimerQuery)i._startTimeQuery=this._createTimeQuery(),t.queryCounterEXT(i._startTimeQuery,t.TIMESTAMP_EXT);else{if(this._currentNonTimestampToken)return this._currentNonTimestampToken;i._timeElapsedQuery=this._createTimeQuery(),t.beginQueryEXT?t.beginQueryEXT(t.TIME_ELAPSED_EXT,i._timeElapsedQuery):this._gl.beginQuery(t.TIME_ELAPSED_EXT,i._timeElapsedQuery),this._currentNonTimestampToken=i}return i},n.prototype.endTimeQuery=function(e){var t=this._caps.timerQuery;if(!t||!e)return-1;if(this._caps.canUseTimestampForTimerQuery){if(!e._startTimeQuery)return-1;e._endTimeQuery||(e._endTimeQuery=this._createTimeQuery(),t.queryCounterEXT(e._endTimeQuery,t.TIMESTAMP_EXT))}else if(!e._timeElapsedQueryEnded){if(!e._timeElapsedQuery)return-1;t.endQueryEXT?t.endQueryEXT(t.TIME_ELAPSED_EXT):this._gl.endQuery(t.TIME_ELAPSED_EXT),e._timeElapsedQueryEnded=!0}var i=this._gl.getParameter(t.GPU_DISJOINT_EXT),r=!1;if(e._endTimeQuery?r=this._getTimeQueryAvailability(e._endTimeQuery):e._timeElapsedQuery&&(r=this._getTimeQueryAvailability(e._timeElapsedQuery)),r&&!i){var n=0;if(this._caps.canUseTimestampForTimerQuery){if(!e._startTimeQuery||!e._endTimeQuery)return-1;var o=this._getTimeQueryResult(e._startTimeQuery);n=this._getTimeQueryResult(e._endTimeQuery)-o,this._deleteTimeQuery(e._startTimeQuery),this._deleteTimeQuery(e._endTimeQuery),e._startTimeQuery=null,e._endTimeQuery=null}else{if(!e._timeElapsedQuery)return-1;n=this._getTimeQueryResult(e._timeElapsedQuery),this._deleteTimeQuery(e._timeElapsedQuery),e._timeElapsedQuery=null,e._timeElapsedQueryEnded=!1,this._currentNonTimestampToken=null}return n}return-1},n.prototype.getGlAlgorithmType=function(t){return t===e.AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE?this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE:this._gl.ANY_SAMPLES_PASSED},n.prototype.createTransformFeedback=function(){return this._gl.createTransformFeedback()},n.prototype.deleteTransformFeedback=function(e){this._gl.deleteTransformFeedback(e)},n.prototype.bindTransformFeedback=function(e){this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK,e)},n.prototype.beginTransformFeedback=function(e){void 0===e&&(e=!0),this._gl.beginTransformFeedback(e?this._gl.POINTS:this._gl.TRIANGLES)},n.prototype.endTransformFeedback=function(){this._gl.endTransformFeedback()},n.prototype.setTranformFeedbackVaryings=function(e,t){this._gl.transformFeedbackVaryings(e,t,this._gl.INTERLEAVED_ATTRIBS)},n.prototype.bindTransformFeedbackBuffer=function(e){this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER,0,e)},n.isSupported=function(){try{var e=document.createElement("canvas");return null!=(e.getContext("webgl")||e.getContext("experimental-webgl"))&&!!window.WebGLRenderingContext}catch(e){return!1}},n.Instances=new Array,n._ALPHA_DISABLE=0,n._ALPHA_ADD=1,n._ALPHA_COMBINE=2,n._ALPHA_SUBTRACT=3,n._ALPHA_MULTIPLY=4,n._ALPHA_MAXIMIZED=5,n._ALPHA_ONEONE=6,n._ALPHA_PREMULTIPLIED=7,n._ALPHA_PREMULTIPLIED_PORTERDUFF=8,n._ALPHA_INTERPOLATE=9,n._ALPHA_SCREENMODE=10,n._DELAYLOADSTATE_NONE=0,n._DELAYLOADSTATE_LOADED=1,n._DELAYLOADSTATE_LOADING=2,n._DELAYLOADSTATE_NOTLOADED=4,n._TEXTUREFORMAT_ALPHA=0,n._TEXTUREFORMAT_LUMINANCE=1,n._TEXTUREFORMAT_LUMINANCE_ALPHA=2,n._TEXTUREFORMAT_RGB=4,n._TEXTUREFORMAT_RGBA=5,n._TEXTURETYPE_UNSIGNED_INT=0,n._TEXTURETYPE_FLOAT=1,n._TEXTURETYPE_HALF_FLOAT=2,n._NEVER=512,n._ALWAYS=519,n._LESS=513,n._EQUAL=514,n._LEQUAL=515,n._GREATER=516,n._GEQUAL=518,n._NOTEQUAL=517,n._KEEP=7680,n._REPLACE=7681,n._INCR=7682,n._DECR=7683,n._INVERT=5386,n._INCR_WRAP=34055,n._DECR_WRAP=34056,n._SCALEMODE_FLOOR=1,n._SCALEMODE_NEAREST=2,n._SCALEMODE_CEILING=3,n.CollisionsEpsilon=.001,n.CodeRepository="src/",n.ShadersRepository="src/Shaders/",n})();e.Engine=u})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i){void 0===i&&(i=null),this.state="",this.metadata=null,this.doNotSerialize=!1,this.animations=new Array,this._ranges={},this._isEnabled=!0,this._isReady=!0,this._currentRenderId=-1,this._parentRenderId=-1,this.onDisposeObservable=new e.Observable,this._behaviors=new Array,this.name=t,this.id=t,this._scene=i||e.Engine.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._initCache()}return Object.defineProperty(t.prototype,"parent",{get:function(){return this._parentNode},set:function(e){if(this._parentNode!==e){if(this._parentNode){var t=this._parentNode._children.indexOf(this);-1!==t&&this._parentNode._children.splice(t,1)}this._parentNode=e,this._parentNode&&(this._parentNode._children||(this._parentNode._children=new Array),this._parentNode._children.push(this))}},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"Node"},Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),t.prototype.getScene=function(){return this._scene},t.prototype.getEngine=function(){return this._scene.getEngine()},t.prototype.addBehavior=function(e){var t=this;if(-1!==this._behaviors.indexOf(e))return this;if(e.init(),this._scene.isLoading)var i=this._scene.onDataLoadedObservable.add((function(){e.attach(t),t._scene.onDataLoadedObservable.remove(i)}));else e.attach(this);return this._behaviors.push(e),this},t.prototype.removeBehavior=function(e){var t=this._behaviors.indexOf(e);return-1===t?this:(this._behaviors[t].detach(),this._behaviors.splice(t,1),this)},Object.defineProperty(t.prototype,"behaviors",{get:function(){return this._behaviors},enumerable:!0,configurable:!0}),t.prototype.getBehaviorByName=function(e){for(var t=0,i=this._behaviors;tthis.maximumWorld.x&&(this.maximumWorld.x=r.x),r.y>this.maximumWorld.y&&(this.maximumWorld.y=r.y),r.z>this.maximumWorld.z&&(this.maximumWorld.z=r.z)}this.maximumWorld.subtractToRef(this.minimumWorld,this.extendSizeWorld),this.extendSizeWorld.scaleInPlace(.5),this.maximumWorld.addToRef(this.minimumWorld,this.centerWorld),this.centerWorld.scaleInPlace(.5),e.Vector3.FromFloatArrayToRef(t.m,0,this.directions[0]),e.Vector3.FromFloatArrayToRef(t.m,4,this.directions[1]),e.Vector3.FromFloatArrayToRef(t.m,8,this.directions[2]),this._worldMatrix=t},t.prototype.isInFrustum=function(e){return t.IsInFrustum(this.vectorsWorld,e)},t.prototype.isCompletelyInFrustum=function(e){return t.IsCompletelyInFrustum(this.vectorsWorld,e)},t.prototype.intersectsPoint=function(t){var i=-e.Epsilon;return!(this.maximumWorld.x-t.xt.x-this.minimumWorld.x)&&(!(this.maximumWorld.y-t.yt.y-this.minimumWorld.y)&&!(this.maximumWorld.z-t.zt.z-this.minimumWorld.z))},t.prototype.intersectsSphere=function(e){return t.IntersectsSphere(this.minimumWorld,this.maximumWorld,e.centerWorld,e.radiusWorld)},t.prototype.intersectsMinMax=function(e,t){return!(this.maximumWorld.xt.x)&&(!(this.maximumWorld.yt.y)&&!(this.maximumWorld.zt.z))},t.Intersects=function(e,t){return!(e.maximumWorld.xt.maximumWorld.x)&&(!(e.maximumWorld.yt.maximumWorld.y)&&!(e.maximumWorld.zt.maximumWorld.z))},t.IntersectsSphere=function(t,i,r,n){var o=e.Vector3.Clamp(r,t,i);return e.Vector3.DistanceSquared(r,o)<=n*n},t.IsCompletelyInFrustum=function(e,t){for(var i=0;i<6;i++)for(var r=0;r<8;r++)if(t[i].dotCoordinate(e[r])<0)return!1;return!0},t.IsInFrustum=function(e,t){for(var i=0;i<6;i++){for(var r=8,n=0;n<8&&t[i].dotCoordinate(e[n])<0;n++)--r;if(0===r)return!1}return!0},t})();e.BoundingBox=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=function(t,i){var r=e.Vector3.Dot(i.centerWorld,t),n=Math.abs(e.Vector3.Dot(i.directions[0],t))*i.extendSize.x,o=Math.abs(e.Vector3.Dot(i.directions[1],t))*i.extendSize.y,s=Math.abs(e.Vector3.Dot(i.directions[2],t))*i.extendSize.z,a=n+o+s;return{min:r-a,max:r+a}},i=function(e,t,i,r){return!(e>r||i>t)},r=function(e,r,n){var o=t(e,r),s=t(e,n);return i(o.min,o.max,s.min,s.max)},n=(function(){function t(t,i){this.minimum=t,this.maximum=i,this._isLocked=!1,this.boundingBox=new e.BoundingBox(t,i),this.boundingSphere=new e.BoundingSphere(t,i)}return Object.defineProperty(t.prototype,"isLocked",{get:function(){return this._isLocked},set:function(e){this._isLocked=e},enumerable:!0,configurable:!0}),t.prototype.update=function(e){this._isLocked||(this.boundingBox._update(e),this.boundingSphere._update(e))},t.prototype.centerOn=function(t,i){return this.minimum=t.subtract(i),this.maximum=t.add(i),this.boundingBox=new e.BoundingBox(this.minimum,this.maximum),this.boundingSphere=new e.BoundingSphere(this.minimum,this.maximum),this},t.prototype.isInFrustum=function(e){return!!this.boundingSphere.isInFrustum(e)&&this.boundingBox.isInFrustum(e)},Object.defineProperty(t.prototype,"diagonalLength",{get:function(){var e=this.boundingBox;return e.maximumWorld.subtract(e.minimumWorld).length()},enumerable:!0,configurable:!0}),t.prototype.isCompletelyInFrustum=function(e){return this.boundingBox.isCompletelyInFrustum(e)},t.prototype._checkCollision=function(e){return e._canDoCollision(this.boundingSphere.centerWorld,this.boundingSphere.radiusWorld,this.boundingBox.minimumWorld,this.boundingBox.maximumWorld)},t.prototype.intersectsPoint=function(e){return!!this.boundingSphere.centerWorld&&(!!this.boundingSphere.intersectsPoint(e)&&!!this.boundingBox.intersectsPoint(e))},t.prototype.intersects=function(t,i){if(!this.boundingSphere.centerWorld||!t.boundingSphere.centerWorld)return!1;if(!e.BoundingSphere.Intersects(this.boundingSphere,t.boundingSphere))return!1;if(!e.BoundingBox.Intersects(this.boundingBox,t.boundingBox))return!1;if(!i)return!0;var n=this.boundingBox,o=t.boundingBox;return!!r(n.directions[0],n,o)&&(!!r(n.directions[1],n,o)&&(!!r(n.directions[2],n,o)&&(!!r(o.directions[0],n,o)&&(!!r(o.directions[1],n,o)&&(!!r(o.directions[2],n,o)&&(!!r(e.Vector3.Cross(n.directions[0],o.directions[0]),n,o)&&(!!r(e.Vector3.Cross(n.directions[0],o.directions[1]),n,o)&&(!!r(e.Vector3.Cross(n.directions[0],o.directions[2]),n,o)&&(!!r(e.Vector3.Cross(n.directions[1],o.directions[0]),n,o)&&(!!r(e.Vector3.Cross(n.directions[1],o.directions[1]),n,o)&&(!!r(e.Vector3.Cross(n.directions[1],o.directions[2]),n,o)&&(!!r(e.Vector3.Cross(n.directions[2],o.directions[0]),n,o)&&(!!r(e.Vector3.Cross(n.directions[2],o.directions[1]),n,o)&&!!r(e.Vector3.Cross(n.directions[2],o.directions[2]),n,o))))))))))))))},t})();e.BoundingInfo=n})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n){void 0===r&&(r=null),void 0===n&&(n=!0);var o=t.call(this,i,r)||this;return o._rotation=e.Vector3.Zero(),o._scaling=e.Vector3.One(),o._isDirty=!1,o.billboardMode=e.AbstractMesh.BILLBOARDMODE_NONE,o.scalingDeterminant=1,o.infiniteDistance=!1,o.position=e.Vector3.Zero(),o._localWorld=e.Matrix.Zero(),o._worldMatrix=e.Matrix.Zero(),o._absolutePosition=e.Vector3.Zero(),o._pivotMatrix=e.Matrix.Identity(),o._postMultiplyPivotMatrix=!1,o._isWorldMatrixFrozen=!1,o.onAfterWorldMatrixUpdateObservable=new e.Observable,o._nonUniformScaling=!1,n&&o.getScene().addTransformNode(o),o}return __extends(i,t),Object.defineProperty(i.prototype,"rotation",{get:function(){return this._rotation},set:function(e){this._rotation=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scaling",{get:function(){return this._scaling},set:function(e){this._scaling=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rotationQuaternion",{get:function(){return this._rotationQuaternion},set:function(e){this._rotationQuaternion=e,e&&this.rotation.length()&&this.rotation.copyFromFloats(0,0,0)},enumerable:!0,configurable:!0}),i.prototype.getWorldMatrix=function(){return this._currentRenderId!==this.getScene().getRenderId()&&this.computeWorldMatrix(),this._worldMatrix},Object.defineProperty(i.prototype,"worldMatrixFromCache",{get:function(){return this._worldMatrix},enumerable:!0,configurable:!0}),i.prototype.updatePoseMatrix=function(e){return this._poseMatrix.copyFrom(e),this},i.prototype.getPoseMatrix=function(){return this._poseMatrix},i.prototype._isSynchronized=function(){return!this._isDirty&&(this.billboardMode===this._cache.billboardMode&&this.billboardMode===e.AbstractMesh.BILLBOARDMODE_NONE&&(!this._cache.pivotMatrixUpdated&&(!this.infiniteDistance&&(!!this._cache.position.equals(this.position)&&(!(this.rotationQuaternion&&!this._cache.rotationQuaternion.equals(this.rotationQuaternion))&&(!!this._cache.rotation.equals(this.rotation)&&!!this._cache.scaling.equals(this.scaling)))))))},i.prototype._initCache=function(){t.prototype._initCache.call(this),this._cache.localMatrixUpdated=!1,this._cache.position=e.Vector3.Zero(),this._cache.scaling=e.Vector3.Zero(),this._cache.rotation=e.Vector3.Zero(),this._cache.rotationQuaternion=new e.Quaternion(0,0,0,0),this._cache.billboardMode=-1},i.prototype.markAsDirty=function(e){return"rotation"===e&&(this.rotationQuaternion=null),this._currentRenderId=Number.MAX_VALUE,this._isDirty=!0,this},Object.defineProperty(i.prototype,"absolutePosition",{get:function(){return this._absolutePosition},enumerable:!0,configurable:!0}),i.prototype.setPivotMatrix=function(t,i){return void 0===i&&(i=!1),this._pivotMatrix=t.clone(),this._cache.pivotMatrixUpdated=!0,this._postMultiplyPivotMatrix=i,this._postMultiplyPivotMatrix&&(this._pivotMatrixInverse=e.Matrix.Invert(t)),this},i.prototype.getPivotMatrix=function(){return this._pivotMatrix},i.prototype.freezeWorldMatrix=function(){return this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0),this._isWorldMatrixFrozen=!0,this},i.prototype.unfreezeWorldMatrix=function(){return this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0),this},Object.defineProperty(i.prototype,"isWorldMatrixFrozen",{get:function(){return this._isWorldMatrixFrozen},enumerable:!0,configurable:!0}),i.prototype.getAbsolutePosition=function(){return this.computeWorldMatrix(),this._absolutePosition},i.prototype.setAbsolutePosition=function(t){if(!t)return this;var i,r,n;if(void 0===t.x){if(arguments.length<3)return this;i=arguments[0],r=arguments[1],n=arguments[2]}else i=t.x,r=t.y,n=t.z;if(this.parent){var o=this.parent.getWorldMatrix().clone();o.invert();var s=new e.Vector3(i,r,n);this.position=e.Vector3.TransformCoordinates(s,o)}else this.position.x=i,this.position.y=r,this.position.z=n;return this},i.prototype.setPositionWithLocalVector=function(t){return this.computeWorldMatrix(),this.position=e.Vector3.TransformNormal(t,this._localWorld),this},i.prototype.getPositionExpressedInLocalSpace=function(){this.computeWorldMatrix();var t=this._localWorld.clone();return t.invert(),e.Vector3.TransformNormal(this.position,t)},i.prototype.locallyTranslate=function(t){return this.computeWorldMatrix(!0),this.position=e.Vector3.TransformCoordinates(t,this._localWorld),this},i.prototype.lookAt=function(t,i,r,n,o){void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=0),void 0===o&&(o=e.Space.LOCAL);var s=e.AbstractMesh._lookAtVectorCache,a=o===e.Space.LOCAL?this.position:this.getAbsolutePosition();t.subtractToRef(a,s);var l=-Math.atan2(s.z,s.x)-Math.PI/2,h=Math.sqrt(s.x*s.x+s.z*s.z),u=Math.atan2(s.y,h);return this.rotationQuaternion=this.rotationQuaternion||new e.Quaternion,e.Quaternion.RotationYawPitchRollToRef(l+i,u+r,n,this.rotationQuaternion),this},i.prototype.getDirection=function(t){var i=e.Vector3.Zero();return this.getDirectionToRef(t,i),i},i.prototype.getDirectionToRef=function(t,i){return e.Vector3.TransformNormalToRef(t,this.getWorldMatrix(),i),this},i.prototype.setPivotPoint=function(t,i){void 0===i&&(i=e.Space.LOCAL),0==this.getScene().getRenderId()&&this.computeWorldMatrix(!0);var r=this.getWorldMatrix();if(i==e.Space.WORLD){var n=e.Tmp.Matrix[0];r.invertToRef(n),t=e.Vector3.TransformCoordinates(t,n)}return e.Vector3.TransformCoordinatesToRef(t,r,this.position),this._pivotMatrix.m[12]=-t.x,this._pivotMatrix.m[13]=-t.y,this._pivotMatrix.m[14]=-t.z,this._cache.pivotMatrixUpdated=!0,this},i.prototype.getPivotPoint=function(){var t=e.Vector3.Zero();return this.getPivotPointToRef(t),t},i.prototype.getPivotPointToRef=function(e){return e.x=-this._pivotMatrix.m[12],e.y=-this._pivotMatrix.m[13],e.z=-this._pivotMatrix.m[14],this},i.prototype.getAbsolutePivotPoint=function(){var t=e.Vector3.Zero();return this.getAbsolutePivotPointToRef(t),t},i.prototype.getAbsolutePivotPointToRef=function(t){return t.x=this._pivotMatrix.m[12],t.y=this._pivotMatrix.m[13],t.z=this._pivotMatrix.m[14],this.getPivotPointToRef(t),e.Vector3.TransformCoordinatesToRef(t,this.getWorldMatrix(),t),this},i.prototype.setParent=function(t){var i=t;if(null==t){var r=e.Tmp.Quaternion[0],n=e.Tmp.Vector3[0],o=e.Tmp.Vector3[1];this.getWorldMatrix().decompose(o,r,n),this.rotationQuaternion?this.rotationQuaternion.copyFrom(r):r.toEulerAnglesToRef(this.rotation),this.position.x=n.x,this.position.y=n.y,this.position.z=n.z}else{var n=e.Tmp.Vector3[0],s=e.Tmp.Matrix[0];i.getWorldMatrix().invertToRef(s),e.Vector3.TransformCoordinatesToRef(this.position,s,n),this.position.copyFrom(n)}return this.parent=i,this}, Object.defineProperty(i.prototype,"nonUniformScaling",{get:function(){return this._nonUniformScaling},enumerable:!0,configurable:!0}),i.prototype._updateNonUniformScalingState=function(e){return this._nonUniformScaling!==e&&(this._nonUniformScaling=!0,!0)},i.prototype.attachToBone=function(e,t){return this._transformToBoneReferal=t,this.parent=e,e.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this},i.prototype.detachFromBone=function(){return this.parent?(this.parent.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this._transformToBoneReferal=null,this.parent=null,this):this},i.prototype.rotate=function(t,i,r){t.normalize(),this.rotationQuaternion||(this.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation=e.Vector3.Zero());var n;if(r&&r!==e.Space.LOCAL){if(this.parent){var o=this.parent.getWorldMatrix().clone();o.invert(),t=e.Vector3.TransformNormal(t,o)}n=e.Quaternion.RotationAxisToRef(t,i,e.AbstractMesh._rotationAxisCache),n.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)}else n=e.Quaternion.RotationAxisToRef(t,i,e.AbstractMesh._rotationAxisCache),this.rotationQuaternion.multiplyToRef(n,this.rotationQuaternion);return this},i.prototype.rotateAround=function(t,i,r){return i.normalize(),this.rotationQuaternion||(this.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation.copyFromFloats(0,0,0)),t.subtractToRef(this.position,e.Tmp.Vector3[0]),e.Matrix.TranslationToRef(e.Tmp.Vector3[0].x,e.Tmp.Vector3[0].y,e.Tmp.Vector3[0].z,e.Tmp.Matrix[0]),e.Tmp.Matrix[0].invertToRef(e.Tmp.Matrix[2]),e.Matrix.RotationAxisToRef(i,r,e.Tmp.Matrix[1]),e.Tmp.Matrix[2].multiplyToRef(e.Tmp.Matrix[1],e.Tmp.Matrix[2]),e.Tmp.Matrix[2].multiplyToRef(e.Tmp.Matrix[0],e.Tmp.Matrix[2]),e.Tmp.Matrix[2].decompose(e.Tmp.Vector3[0],e.Tmp.Quaternion[0],e.Tmp.Vector3[1]),this.position.addInPlace(e.Tmp.Vector3[1]),e.Tmp.Quaternion[0].multiplyToRef(this.rotationQuaternion,this.rotationQuaternion),this},i.prototype.translate=function(t,i,r){var n=t.scale(i);if(r&&r!==e.Space.LOCAL)this.setAbsolutePosition(this.getAbsolutePosition().add(n));else{var o=this.getPositionExpressedInLocalSpace().add(n);this.setPositionWithLocalVector(o)}return this},i.prototype.addRotation=function(t,i,r){var n;this.rotationQuaternion?n=this.rotationQuaternion:(n=e.Tmp.Quaternion[1],e.Quaternion.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,n));var o=e.Tmp.Quaternion[0];return e.Quaternion.RotationYawPitchRollToRef(i,t,r,o),n.multiplyInPlace(o),this.rotationQuaternion||n.toEulerAnglesToRef(this.rotation),this},i.prototype.computeWorldMatrix=function(t){if(this._isWorldMatrixFrozen)return this._worldMatrix;if(!t&&this.isSynchronized(!0))return this._worldMatrix;if(this._cache.position.copyFrom(this.position),this._cache.scaling.copyFrom(this.scaling),this._cache.pivotMatrixUpdated=!1,this._cache.billboardMode=this.billboardMode,this._currentRenderId=this.getScene().getRenderId(),this._isDirty=!1,e.Matrix.ScalingToRef(this.scaling.x*this.scalingDeterminant,this.scaling.y*this.scalingDeterminant,this.scaling.z*this.scalingDeterminant,e.Tmp.Matrix[1]),this.rotationQuaternion){this.rotation.length()&&(this.rotationQuaternion.multiplyInPlace(e.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z)),this.rotation.copyFromFloats(0,0,0))}this.rotationQuaternion?(this.rotationQuaternion.toRotationMatrix(e.Tmp.Matrix[0]),this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)):(e.Matrix.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,e.Tmp.Matrix[0]),this._cache.rotation.copyFrom(this.rotation));var i=this.getScene().activeCamera;if(this.infiniteDistance&&!this.parent&&i){var r=i.getWorldMatrix(),n=new e.Vector3(r.m[12],r.m[13],r.m[14]);e.Matrix.TranslationToRef(this.position.x+n.x,this.position.y+n.y,this.position.z+n.z,e.Tmp.Matrix[2])}else e.Matrix.TranslationToRef(this.position.x,this.position.y,this.position.z,e.Tmp.Matrix[2]);if(this._pivotMatrix.multiplyToRef(e.Tmp.Matrix[1],e.Tmp.Matrix[4]),e.Tmp.Matrix[4].multiplyToRef(e.Tmp.Matrix[0],e.Tmp.Matrix[5]),this.billboardMode!==e.AbstractMesh.BILLBOARDMODE_NONE&&i){if((this.billboardMode&e.AbstractMesh.BILLBOARDMODE_ALL)!==e.AbstractMesh.BILLBOARDMODE_ALL){var o=e.Tmp.Vector3[3];this.parent&&this.parent.getWorldMatrix?this._transformToBoneReferal?(this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),e.Tmp.Matrix[6]),e.Vector3.TransformCoordinatesToRef(this.position,e.Tmp.Matrix[6],o)):e.Vector3.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),o):o.copyFrom(this.position),o.subtractInPlace(i.globalPosition);var s=e.Tmp.Vector3[4].copyFromFloats(0,0,0);(this.billboardMode&e.AbstractMesh.BILLBOARDMODE_X)===e.AbstractMesh.BILLBOARDMODE_X&&(s.x=Math.atan2(-o.y,o.z)),(this.billboardMode&e.AbstractMesh.BILLBOARDMODE_Y)===e.AbstractMesh.BILLBOARDMODE_Y&&(s.y=Math.atan2(o.x,o.z)),(this.billboardMode&e.AbstractMesh.BILLBOARDMODE_Z)===e.AbstractMesh.BILLBOARDMODE_Z&&(s.z=Math.atan2(o.y,o.x)),e.Matrix.RotationYawPitchRollToRef(s.y,s.x,s.z,e.Tmp.Matrix[0])}else e.Tmp.Matrix[1].copyFrom(i.getViewMatrix()),e.Tmp.Matrix[1].setTranslationFromFloats(0,0,0),e.Tmp.Matrix[1].invertToRef(e.Tmp.Matrix[0]);e.Tmp.Matrix[1].copyFrom(e.Tmp.Matrix[5]),e.Tmp.Matrix[1].multiplyToRef(e.Tmp.Matrix[0],e.Tmp.Matrix[5])}return e.Tmp.Matrix[5].multiplyToRef(e.Tmp.Matrix[2],this._localWorld),this.parent&&this.parent.getWorldMatrix?(this.billboardMode!==e.AbstractMesh.BILLBOARDMODE_NONE?(this._transformToBoneReferal?(this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),e.Tmp.Matrix[6]),e.Tmp.Matrix[5].copyFrom(e.Tmp.Matrix[6])):e.Tmp.Matrix[5].copyFrom(this.parent.getWorldMatrix()),this._localWorld.getTranslationToRef(e.Tmp.Vector3[5]),e.Vector3.TransformCoordinatesToRef(e.Tmp.Vector3[5],e.Tmp.Matrix[5],e.Tmp.Vector3[5]),this._worldMatrix.copyFrom(this._localWorld),this._worldMatrix.setTranslation(e.Tmp.Vector3[5])):this._transformToBoneReferal?(this._localWorld.multiplyToRef(this.parent.getWorldMatrix(),e.Tmp.Matrix[6]),e.Tmp.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),this._worldMatrix)):this._localWorld.multiplyToRef(this.parent.getWorldMatrix(),this._worldMatrix),this._markSyncedWithParent()):this._worldMatrix.copyFrom(this._localWorld),this._postMultiplyPivotMatrix&&this._worldMatrix.multiplyToRef(this._pivotMatrixInverse,this._worldMatrix),this.scaling.isNonUniform?this._updateNonUniformScalingState(!0):this.parent&&this.parent._nonUniformScaling?this._updateNonUniformScalingState(this.parent._nonUniformScaling):this._updateNonUniformScalingState(!1),this._afterComputeWorldMatrix(),this._absolutePosition.copyFromFloats(this._worldMatrix.m[12],this._worldMatrix.m[13],this._worldMatrix.m[14]),this.onAfterWorldMatrixUpdateObservable.notifyObservers(this),this._poseMatrix||(this._poseMatrix=e.Matrix.Invert(this._worldMatrix)),this._worldMatrix},i.prototype._afterComputeWorldMatrix=function(){},i.prototype.registerAfterWorldMatrixUpdate=function(e){return this.onAfterWorldMatrixUpdateObservable.add(e),this},i.prototype.unregisterAfterWorldMatrixUpdate=function(e){return this.onAfterWorldMatrixUpdateObservable.removeCallback(e),this},i.prototype.clone=function(t,r){var n=this,o=e.SerializationHelper.Clone((function(){return new i(t,n.getScene())}),this);return o.name=t,o.id=t,r&&(o.parent=r),o},i.prototype.serialize=function(t){return void 0===t&&(t=null),t||(t={}),t.name=this.name,t.id=this.id,t.type=this.getClassName(),e.Tags&&e.Tags.HasTags(this)&&(t.tags=e.Tags.GetTags(this)),t.position=this.position.asArray(),this.rotationQuaternion?t.rotationQuaternion=this.rotationQuaternion.asArray():this.rotation&&(t.rotation=this.rotation.asArray()),t.scaling=this.scaling.asArray(),t.localMatrix=this.getPivotMatrix().asArray(),t.isEnabled=this.isEnabled(),t.infiniteDistance=this.infiniteDistance,t.billboardMode=this.billboardMode,this.parent&&(t.parentId=this.parent.id),this.metadata&&(t.metadata=this.metadata),t},i.Parse=function(t,r,n){var o=new i(t.name,r);return o.id=t.id,e.Tags&&e.Tags.AddTagsTo(o,t.tags),o.position=e.Vector3.FromArray(t.position),void 0!==t.metadata&&(o.metadata=t.metadata),t.rotationQuaternion?o.rotationQuaternion=e.Quaternion.FromArray(t.rotationQuaternion):t.rotation&&(o.rotation=e.Vector3.FromArray(t.rotation)),o.scaling=e.Vector3.FromArray(t.scaling),t.localMatrix?o.setPivotMatrix(e.Matrix.FromArray(t.localMatrix)):t.pivotMatrix&&o.setPivotMatrix(e.Matrix.FromArray(t.pivotMatrix)),o.setEnabled(t.isEnabled),o.infiniteDistance=t.infiniteDistance,o.billboardMode=t.billboardMode,t.parentId&&(o._waitingParentId=t.parentId),o},i.BILLBOARDMODE_NONE=0,i.BILLBOARDMODE_X=1,i.BILLBOARDMODE_Y=2,i.BILLBOARDMODE_Z=4,i.BILLBOARDMODE_ALL=7,i._lookAtVectorCache=new e.Vector3(0,0,0),i._rotationAxisCache=new e.Quaternion,i})(e.Node);e.TransformNode=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(r,n){void 0===n&&(n=null);var o=t.call(this,r,n,!1)||this;return o._facetNb=0,o._partitioningSubdivisions=10,o._partitioningBBoxRatio=1.01,o._facetDataEnabled=!1,o._facetParameters={},o._bbSize=e.Vector3.Zero(),o._subDiv={max:1,X:1,Y:1,Z:1},o._facetDepthSort=!1,o._facetDepthSortEnabled=!1,o.onCollideObservable=new e.Observable,o.onCollisionPositionChangeObservable=new e.Observable,o.onMaterialChangedObservable=new e.Observable,o.definedFacingForward=!0,o.occlusionQueryAlgorithmType=i.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE,o.occlusionType=i.OCCLUSION_TYPE_NONE,o.occlusionRetryCount=-1,o._occlusionInternalRetryCounter=0,o._isOccluded=!1,o._isOcclusionQueryInProgress=!1,o.visibility=1,o.alphaIndex=Number.MAX_VALUE,o.isVisible=!0,o.isPickable=!0,o.showBoundingBox=!1,o.showSubMeshesBoundingBox=!1,o.isBlocker=!1,o.enablePointerMoveEvents=!1,o.renderingGroupId=0,o._receiveShadows=!1,o.renderOutline=!1,o.outlineColor=e.Color3.Red(),o.outlineWidth=.02,o.renderOverlay=!1,o.overlayColor=e.Color3.Red(),o.overlayAlpha=.5,o._hasVertexAlpha=!1,o._useVertexColors=!0,o._computeBonesUsingShaders=!0,o._numBoneInfluencers=4,o._applyFog=!0,o.useOctreeForRenderingSelection=!0,o.useOctreeForPicking=!0,o.useOctreeForCollisions=!0,o._layerMask=268435455,o.alwaysSelectAsActiveMesh=!1,o._checkCollisions=!1,o._collisionMask=-1,o._collisionGroup=-1,o.ellipsoid=new e.Vector3(.5,1,.5),o.ellipsoidOffset=new e.Vector3(0,0,0),o._oldPositionForCollisions=new e.Vector3(0,0,0),o._diffPositionForCollisions=new e.Vector3(0,0,0),o.edgesWidth=1,o.edgesColor=new e.Color4(1,0,0,1),o._collisionsTransformMatrix=e.Matrix.Zero(),o._collisionsScalingMatrix=e.Matrix.Zero(),o._isDisposed=!1,o._renderId=0,o._intersectionsInProgress=new Array,o._unIndexed=!1,o._lightSources=new Array,o._onCollisionPositionChange=function(t,i,r){void 0===r&&(r=null),o.getScene().workerCollisions&&i.multiplyInPlace(o._collider.radius),i.subtractToRef(o._oldPositionForCollisions,o._diffPositionForCollisions),o._diffPositionForCollisions.length()>e.Engine.CollisionsEpsilon&&o.position.addInPlace(o._diffPositionForCollisions),r&&o.onCollideObservable.notifyObservers(r),o.onCollisionPositionChangeObservable.notifyObservers(o.position)},o.getScene().addMesh(o),o._resyncLightSources(),o}return __extends(i,t),Object.defineProperty(i,"BILLBOARDMODE_NONE",{get:function(){return e.TransformNode.BILLBOARDMODE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_X",{get:function(){return e.TransformNode.BILLBOARDMODE_X},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_Y",{get:function(){return e.TransformNode.BILLBOARDMODE_Y},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_Z",{get:function(){return e.TransformNode.BILLBOARDMODE_Z},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_ALL",{get:function(){return e.TransformNode.BILLBOARDMODE_ALL},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"facetNb",{get:function(){return this._facetNb},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"partitioningSubdivisions",{get:function(){return this._partitioningSubdivisions},set:function(e){this._partitioningSubdivisions=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"partitioningBBoxRatio",{get:function(){return this._partitioningBBoxRatio},set:function(e){this._partitioningBBoxRatio=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"mustDepthSortFacets",{get:function(){return this._facetDepthSort},set:function(e){this._facetDepthSort=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"facetDepthSortFrom",{get:function(){return this._facetDepthSortFrom},set:function(e){this._facetDepthSortFrom=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isFacetDataEnabled",{get:function(){return this._facetDataEnabled},enumerable:!0,configurable:!0}),i.prototype._updateNonUniformScalingState=function(e){return!!t.prototype._updateNonUniformScalingState.call(this,e)&&(this._markSubMeshesAsMiscDirty(),!0)},Object.defineProperty(i.prototype,"onCollide",{set:function(e){this._onCollideObserver&&this.onCollideObservable.remove(this._onCollideObserver),this._onCollideObserver=this.onCollideObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onCollisionPositionChange",{set:function(e){this._onCollisionPositionChangeObserver&&this.onCollisionPositionChangeObservable.remove(this._onCollisionPositionChangeObserver),this._onCollisionPositionChangeObserver=this.onCollisionPositionChangeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isOccluded",{get:function(){return this._isOccluded},set:function(e){this._isOccluded=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isOcclusionQueryInProgress",{get:function(){return this._isOcclusionQueryInProgress},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"material",{get:function(){return this._material},set:function(e){if(this._material!==e&&(this._material=e,this.onMaterialChangedObservable.hasObservers&&this.onMaterialChangedObservable.notifyObservers(this),this.subMeshes))for(var t=0,i=this.subMeshes;t1&&!a._checkCollision(e)||this._collideForSubMesh(a,t,e)}return this},i.prototype._checkCollision=function(t){return this._boundingInfo&&this._boundingInfo._checkCollision(t)?(e.Matrix.ScalingToRef(1/t.radius.x,1/t.radius.y,1/t.radius.z,this._collisionsScalingMatrix),this.worldMatrixFromCache.multiplyToRef(this._collisionsScalingMatrix,this._collisionsTransformMatrix),this._processCollisionsForSubMeshes(t,this._collisionsTransformMatrix),this):this},i.prototype._generatePointsArray=function(){return!1},i.prototype.intersects=function(t,i){var r=new e.PickingInfo;if(!(this.subMeshes&&this._boundingInfo&&t.intersectsSphere(this._boundingInfo.boundingSphere)&&t.intersectsBox(this._boundingInfo.boundingBox)))return r;if(!this._generatePointsArray())return r;var n,o,s=null;if(this._submeshesOctree&&this.useOctreeForPicking){var a=e.Ray.Transform(t,this.getWorldMatrix()),l=this._submeshesOctree.intersectsRay(a);o=l.length,n=l.data}else n=this.subMeshes,o=n.length;for(var h=0;h1)||u.canIntersects(t)){var c=u.intersects(t,this._positions,this.getIndices(),i);if(c&&(i||!s||c.distance65535){o=!0;break}this._depthSortedIndices=o?new Uint32Array(i):new Uint16Array(i)}if(this._facetDepthSortFunction=function(e,t){return t.sqDistance-e.sqDistance},!this._facetDepthSortFrom){var a=this.getScene().activeCamera;this._facetDepthSortFrom=a?a.position:e.Vector3.Zero()}this._depthSortedFacets=[];for(var l=0;le.Epsilon?n.maximum.x-n.minimum.x:e.Epsilon,this._bbSize.y=n.maximum.y-n.minimum.y>e.Epsilon?n.maximum.y-n.minimum.y:e.Epsilon,this._bbSize.z=n.maximum.z-n.minimum.z>e.Epsilon?n.maximum.z-n.minimum.z:e.Epsilon;var u=this._bbSize.x>this._bbSize.y?this._bbSize.x:this._bbSize.y;if(u=u>this._bbSize.z?u:this._bbSize.z, this._subDiv.max=this._partitioningSubdivisions,this._subDiv.X=Math.floor(this._subDiv.max*this._bbSize.x/u),this._subDiv.Y=Math.floor(this._subDiv.max*this._bbSize.y/u),this._subDiv.Z=Math.floor(this._subDiv.max*this._bbSize.z/u),this._subDiv.X=this._subDiv.X<1?1:this._subDiv.X,this._subDiv.Y=this._subDiv.Y<1?1:this._subDiv.Y,this._subDiv.Z=this._subDiv.Z<1?1:this._subDiv.Z,this._facetParameters.facetNormals=this.getFacetLocalNormals(),this._facetParameters.facetPositions=this.getFacetLocalPositions(),this._facetParameters.facetPartitioning=this.getFacetLocalPartitioning(),this._facetParameters.bInfo=n,this._facetParameters.bbSize=this._bbSize,this._facetParameters.subDiv=this._subDiv,this._facetParameters.ratio=this.partitioningBBoxRatio,this._facetParameters.depthSort=this._facetDepthSort,this._facetDepthSort&&this._facetDepthSortEnabled&&(this.computeWorldMatrix(!0),this._worldMatrix.invertToRef(this._invertedMatrix),e.Vector3.TransformCoordinatesToRef(this._facetDepthSortFrom,this._invertedMatrix,this._facetDepthSortOrigin),this._facetParameters.distanceTo=this._facetDepthSortOrigin),this._facetParameters.depthSortedFacets=this._depthSortedFacets,e.VertexData.ComputeNormals(t,i,r,this._facetParameters),this._facetDepthSort&&this._facetDepthSortEnabled){this._depthSortedFacets.sort(this._facetDepthSortFunction);for(var c=this._depthSortedIndices.length/3|0,l=0;lthis._subDiv.max||o<0||o>this._subDiv.max||s<0||s>this._subDiv.max?null:this._facetPartitioning[n+this._subDiv.max*o+this._subDiv.max*this._subDiv.max*s]},i.prototype.getClosestFacetAtCoordinates=function(t,i,r,n,o,s){void 0===o&&(o=!1),void 0===s&&(s=!0);var a=this.getWorldMatrix(),l=e.Tmp.Matrix[5];a.invertToRef(l);var h=e.Tmp.Vector3[8];e.Vector3.TransformCoordinatesFromFloatsToRef(t,i,r,l,h);var u=this.getClosestFacetAtLocalCoordinates(h.x,h.y,h.z,n,o,s);return n&&e.Vector3.TransformCoordinatesFromFloatsToRef(n.x,n.y,n.z,a,n),u},i.prototype.getClosestFacetAtLocalCoordinates=function(e,t,i,r,n,o){void 0===n&&(n=!1),void 0===o&&(o=!0);var s=null,a=0,l=0,h=0,u=0,c=0,f=0,d=0,p=0,_=this.getFacetLocalPositions(),m=this.getFacetLocalNormals(),g=this.getFacetsAtLocalCoordinates(e,t,i);if(!g)return null;for(var v,y,b,x=Number.MAX_VALUE,T=x,A=0;A=0||n&&!o&&u<=0)&&(u=y.x*b.x+y.y*b.y+y.z*b.z,c=-(y.x*e+y.y*t+y.z*i-u)/(y.x*y.x+y.y*y.y+y.z*y.z),f=e+y.x*c,d=t+y.y*c,p=i+y.z*c,a=f-e,l=d-t,h=p-i,(T=a*a+l*l+h*h)this.occlusionRetryCount))return;this._isOcclusionQueryInProgress=!1,this._occlusionInternalRetryCounter=0,this._isOccluded=this.occlusionType!==i.OCCLUSION_TYPE_OPTIMISTIC&&this._isOccluded}}var r=this.getScene(),n=r.getBoundingBoxRenderer();this._occlusionQuery||(this._occlusionQuery=e.createQuery()),e.beginOcclusionQuery(this.occlusionQueryAlgorithmType,this._occlusionQuery),n.renderOcclusionBoundingBox(this),e.endOcclusionQuery(this.occlusionQueryAlgorithmType),this._isOcclusionQueryInProgress=!0},i.OCCLUSION_TYPE_NONE=0,i.OCCLUSION_TYPE_OPTIMISTIC=1,i.OCCLUSION_TYPE_STRICT=2,i.OCCLUSION_ALGORITHM_TYPE_ACCURATE=0,i.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE=1,i})(e.TransformNode);e.AbstractMesh=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(r,n){var o=t.call(this,r,n)||this;return o.diffuse=new e.Color3(1,1,1),o.specular=new e.Color3(1,1,1),o.intensity=1,o.range=Number.MAX_VALUE,o._photometricScale=1,o._intensityMode=i.INTENSITYMODE_AUTOMATIC,o._radius=1e-5,o.renderPriority=0,o.shadowEnabled=!0,o._excludeWithLayerMask=0,o._includeOnlyWithLayerMask=0,o._lightmapMode=0,o._excludedMeshesIds=new Array,o._includedOnlyMeshesIds=new Array,o.getScene().addLight(o),o._uniformBuffer=new e.UniformBuffer(o.getScene().getEngine()),o._buildUniformLayout(),o.includedOnlyMeshes=new Array,o.excludedMeshes=new Array,o._resyncMeshes(),o}return __extends(i,t),Object.defineProperty(i,"LIGHTMAP_DEFAULT",{get:function(){return i._LIGHTMAP_DEFAULT},enumerable:!0,configurable:!0}),Object.defineProperty(i,"LIGHTMAP_SPECULAR",{get:function(){return i._LIGHTMAP_SPECULAR},enumerable:!0,configurable:!0}),Object.defineProperty(i,"LIGHTMAP_SHADOWSONLY",{get:function(){return i._LIGHTMAP_SHADOWSONLY},enumerable:!0,configurable:!0}),Object.defineProperty(i,"INTENSITYMODE_AUTOMATIC",{get:function(){return i._INTENSITYMODE_AUTOMATIC},enumerable:!0,configurable:!0}),Object.defineProperty(i,"INTENSITYMODE_LUMINOUSPOWER",{get:function(){return i._INTENSITYMODE_LUMINOUSPOWER},enumerable:!0,configurable:!0}),Object.defineProperty(i,"INTENSITYMODE_LUMINOUSINTENSITY",{get:function(){return i._INTENSITYMODE_LUMINOUSINTENSITY},enumerable:!0,configurable:!0}),Object.defineProperty(i,"INTENSITYMODE_ILLUMINANCE",{get:function(){return i._INTENSITYMODE_ILLUMINANCE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"INTENSITYMODE_LUMINANCE",{get:function(){return i._INTENSITYMODE_LUMINANCE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"LIGHTTYPEID_POINTLIGHT",{get:function(){return i._LIGHTTYPEID_POINTLIGHT},enumerable:!0,configurable:!0}),Object.defineProperty(i,"LIGHTTYPEID_DIRECTIONALLIGHT",{get:function(){return i._LIGHTTYPEID_DIRECTIONALLIGHT},enumerable:!0,configurable:!0}),Object.defineProperty(i,"LIGHTTYPEID_SPOTLIGHT",{get:function(){return i._LIGHTTYPEID_SPOTLIGHT},enumerable:!0,configurable:!0}),Object.defineProperty(i,"LIGHTTYPEID_HEMISPHERICLIGHT",{get:function(){return i._LIGHTTYPEID_HEMISPHERICLIGHT},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"intensityMode",{get:function(){return this._intensityMode},set:function(e){this._intensityMode=e,this._computePhotometricScale()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"radius",{get:function(){return this._radius},set:function(e){this._radius=e,this._computePhotometricScale()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"includedOnlyMeshes",{get:function(){return this._includedOnlyMeshes},set:function(e){this._includedOnlyMeshes=e,this._hookArrayForIncludedOnly(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"excludedMeshes",{get:function(){return this._excludedMeshes},set:function(e){this._excludedMeshes=e,this._hookArrayForExcluded(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"excludeWithLayerMask",{get:function(){return this._excludeWithLayerMask},set:function(e){this._excludeWithLayerMask=e,this._resyncMeshes()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"includeOnlyWithLayerMask",{get:function(){return this._includeOnlyWithLayerMask},set:function(e){this._includeOnlyWithLayerMask=e,this._resyncMeshes()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"lightmapMode",{get:function(){return this._lightmapMode},set:function(e){this._lightmapMode!==e&&(this._lightmapMode=e,this._markMeshesAsLightDirty())},enumerable:!0,configurable:!0}),i.prototype._buildUniformLayout=function(){},i.prototype.getClassName=function(){return"Light"},i.prototype.toString=function(e){var t="Name: "+this.name;if(t+=", type: "+["Point","Directional","Spot","Hemispheric"][this.getTypeID()],this.animations)for(var i=0;i0&&-1===this.includedOnlyMeshes.indexOf(e))&&(!(this.excludedMeshes&&this.excludedMeshes.length>0&&-1!==this.excludedMeshes.indexOf(e))&&((0===this.includeOnlyWithLayerMask||0!=(this.includeOnlyWithLayerMask&e.layerMask))&&!(0!==this.excludeWithLayerMask&&this.excludeWithLayerMask&e.layerMask)))},i.prototype.getWorldMatrix=function(){this._currentRenderId=this.getScene().getRenderId();var t=this._getWorldMatrix();return this.parent&&this.parent.getWorldMatrix?(this._parentedWorldMatrix||(this._parentedWorldMatrix=e.Matrix.Identity()),t.multiplyToRef(this.parent.getWorldMatrix(),this._parentedWorldMatrix),this._markSyncedWithParent(),this._parentedWorldMatrix):t},i.compareLightsPriority=function(e,t){return e.shadowEnabled!==t.shadowEnabled?(t.shadowEnabled?1:0)-(e.shadowEnabled?1:0):t.renderPriority-e.renderPriority},i.prototype.dispose=function(){this._shadowGenerator&&(this._shadowGenerator.dispose(),this._shadowGenerator=null),this.getScene().stopAnimation(this);for(var e=0,i=this.getScene().meshes;e0&&(t.excludedMeshesIds=[],this.excludedMeshes.forEach((function(e){t.excludedMeshesIds.push(e.id)}))),this.includedOnlyMeshes.length>0&&(t.includedOnlyMeshesIds=[],this.includedOnlyMeshes.forEach((function(e){t.includedOnlyMeshesIds.push(e.id)}))),e.Animation.AppendSerializedAnimations(this,t),t.ranges=this.serializeAnimationRanges(),t},i.GetConstructorFromName=function(t,i,r){switch(t){case 0:return function(){return new e.PointLight(i,e.Vector3.Zero(),r)};case 1:return function(){return new e.DirectionalLight(i,e.Vector3.Zero(),r)};case 2:return function(){return new e.SpotLight(i,e.Vector3.Zero(),e.Vector3.Zero(),0,0,r)};case 3:return function(){return new e.HemisphericLight(i,e.Vector3.Zero(),r)}}return null},i.Parse=function(t,r){var n=i.GetConstructorFromName(t.type,t.name,r);if(!n)return null;var o=e.SerializationHelper.Parse(n,t,r);if(t.excludedMeshesIds&&(o._excludedMeshesIds=t.excludedMeshesIds),t.includedOnlyMeshesIds&&(o._includedOnlyMeshesIds=t.includedOnlyMeshesIds),t.parentId&&(o._waitingParentId=t.parentId),t.animations){for(var s=0;s0&&this._postProcesses[0].markTextureDirty();for(var t=0,i=this._rigCameras.length;t-1?(e.Tools.Error("You're trying to reuse a post process not defined as reusable."),0):(null==i||i<0?this._postProcesses.push(t):this._postProcesses.splice(i,0,t),this._cascadePostProcessesToRigCams(),this._postProcesses.indexOf(t))},i.prototype.detachPostProcess=function(e){var t=this._postProcesses.indexOf(e);-1!==t&&this._postProcesses.splice(t,1),this._cascadePostProcessesToRigCams()},i.prototype.getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),this.getViewMatrix().invertToRef(this._worldMatrix),this._worldMatrix},i.prototype._getViewMatrix=function(){return e.Matrix.Identity()},i.prototype.getViewMatrix=function(t){return!t&&this._isSynchronizedViewMatrix()?this._computedViewMatrix:(this.updateCache(),this._computedViewMatrix=this._getViewMatrix(),this._currentRenderId=this.getScene().getRenderId(),this._refreshFrustumPlanes=!0,this.parent&&this.parent.getWorldMatrix?(this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),this._computedViewMatrix.invertToRef(this._worldMatrix),this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(),this._computedViewMatrix),this._globalPosition.copyFromFloats(this._computedViewMatrix.m[12],this._computedViewMatrix.m[13],this._computedViewMatrix.m[14]),this._computedViewMatrix.invert(),this._markSyncedWithParent()):this._globalPosition.copyFrom(this.position),this._cameraRigParams&&this._cameraRigParams.vrPreViewMatrix&&this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix,this._computedViewMatrix),this.onViewMatrixChangedObservable.notifyObservers(this),this._computedViewMatrix)},i.prototype.freezeProjectionMatrix=function(e){this._doNotComputeProjectionMatrix=!0,void 0!==e&&(this._projectionMatrix=e)},i.prototype.unfreezeProjectionMatrix=function(){this._doNotComputeProjectionMatrix=!1},i.prototype.getProjectionMatrix=function(t){if(this._doNotComputeProjectionMatrix||!t&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;this._cache.mode=this.mode,this._cache.minZ=this.minZ,this._cache.maxZ=this.maxZ,this._refreshFrustumPlanes=!0;var r=this.getEngine(),n=this.getScene();if(this.mode===i.PERSPECTIVE_CAMERA)this._cache.fov=this.fov,this._cache.fovMode=this.fovMode,this._cache.aspectRatio=r.getAspectRatio(this),this.minZ<=0&&(this.minZ=.1),n.useRightHandedSystem?e.Matrix.PerspectiveFovRHToRef(this.fov,r.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===i.FOVMODE_VERTICAL_FIXED):e.Matrix.PerspectiveFovLHToRef(this.fov,r.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===i.FOVMODE_VERTICAL_FIXED);else{var o=r.getRenderWidth()/2,s=r.getRenderHeight()/2;n.useRightHandedSystem?e.Matrix.OrthoOffCenterRHToRef(this.orthoLeft||-o,this.orthoRight||o,this.orthoBottom||-s,this.orthoTop||s,this.minZ,this.maxZ,this._projectionMatrix):e.Matrix.OrthoOffCenterLHToRef(this.orthoLeft||-o,this.orthoRight||o,this.orthoBottom||-s,this.orthoTop||s,this.minZ,this.maxZ,this._projectionMatrix),this._cache.orthoLeft=this.orthoLeft,this._cache.orthoRight=this.orthoRight,this._cache.orthoBottom=this.orthoBottom,this._cache.orthoTop=this.orthoTop,this._cache.renderWidth=r.getRenderWidth(),this._cache.renderHeight=r.getRenderHeight()}return this.onProjectionMatrixChangedObservable.notifyObservers(this),this._projectionMatrix},i.prototype.getTranformationMatrix=function(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix},i.prototype.updateFrustumPlanes=function(){this._refreshFrustumPlanes&&(this.getTranformationMatrix(),this._frustumPlanes?e.Frustum.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=e.Frustum.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)},i.prototype.isInFrustum=function(e){return this.updateFrustumPlanes(),e.isInFrustum(this._frustumPlanes)},i.prototype.isCompletelyInFrustum=function(e){return this.updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)},i.prototype.getForwardRay=function(t,i,r){void 0===t&&(t=100),i||(i=this.getWorldMatrix()),r||(r=this.position);var n=new e.Vector3(0,0,1),o=e.Vector3.TransformNormal(n,i),s=e.Vector3.Normalize(o);return new e.Ray(r,s,t)},i.prototype.dispose=function(){for(this.onViewMatrixChangedObservable.clear(),this.onProjectionMatrixChangedObservable.clear(),this.onAfterCheckInputsObservable.clear(),this.onRestoreStateObservable.clear(),this.inputs&&this.inputs.clear(),this.getScene().stopAnimation(this),this.getScene().removeCamera(this);this._rigCameras.length>0;){var e=this._rigCameras.pop();e&&e.dispose()}if(this._rigPostProcess)this._rigPostProcess.dispose(this),this._rigPostProcess=null,this._postProcesses=[];else if(this.cameraRigMode!==i.RIG_MODE_NONE)this._rigPostProcess=null,this._postProcesses=[];else for(var r=this._postProcesses.length;--r>=0;)this._postProcesses[r].dispose(this);for(var r=this.customRenderTargets.length;--r>=0;)this.customRenderTargets[r].dispose();this.customRenderTargets=[],this._activeMeshes.dispose(),t.prototype.dispose.call(this)},Object.defineProperty(i.prototype,"leftCamera",{get:function(){return this._rigCameras.length<1?null:this._rigCameras[0]},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rightCamera",{get:function(){return this._rigCameras.length<2?null:this._rigCameras[1]},enumerable:!0,configurable:!0}),i.prototype.getLeftTarget=function(){return this._rigCameras.length<1?null:this._rigCameras[0].getTarget()},i.prototype.getRightTarget=function(){return this._rigCameras.length<2?null:this._rigCameras[1].getTarget()},i.prototype.setCameraRigMode=function(t,r){if(this.cameraRigMode!==t){for(;this._rigCameras.length>0;){var n=this._rigCameras.pop();n&&n.dispose()}if(this.cameraRigMode=t,this._cameraRigParams={},this._cameraRigParams.interaxialDistance=r.interaxialDistance||.0637,this._cameraRigParams.stereoHalfAngle=e.Tools.ToRadians(this._cameraRigParams.interaxialDistance/.0637),this.cameraRigMode!==i.RIG_MODE_NONE){var o=this.createRigCamera(this.name+"_L",0),s=this.createRigCamera(this.name+"_R",1);o&&s&&(this._rigCameras.push(o),this._rigCameras.push(s))}switch(this.cameraRigMode){case i.RIG_MODE_STEREOSCOPIC_ANAGLYPH:this._rigCameras[0]._rigPostProcess=new e.PassPostProcess(this.name+"_passthru",1,this._rigCameras[0]),this._rigCameras[1]._rigPostProcess=new e.AnaglyphPostProcess(this.name+"_anaglyph",1,this._rigCameras);break;case i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case i.RIG_MODE_STEREOSCOPIC_OVERUNDER:var a=this.cameraRigMode===i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL||this.cameraRigMode===i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;this._rigCameras[0]._rigPostProcess=new e.PassPostProcess(this.name+"_passthru",1,this._rigCameras[0]),this._rigCameras[1]._rigPostProcess=new e.StereoscopicInterlacePostProcess(this.name+"_stereoInterlace",this._rigCameras,a);break;case i.RIG_MODE_VR:var l=r.vrCameraMetrics||e.VRCameraMetrics.GetDefault();this._rigCameras[0]._cameraRigParams.vrMetrics=l,this._rigCameras[0].viewport=new e.Viewport(0,0,.5,1),this._rigCameras[0]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[0]._cameraRigParams.vrHMatrix=l.leftHMatrix,this._rigCameras[0]._cameraRigParams.vrPreViewMatrix=l.leftPreViewMatrix,this._rigCameras[0].getProjectionMatrix=this._rigCameras[0]._getVRProjectionMatrix,this._rigCameras[1]._cameraRigParams.vrMetrics=l,this._rigCameras[1].viewport=new e.Viewport(.5,0,.5,1),this._rigCameras[1]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[1]._cameraRigParams.vrHMatrix=l.rightHMatrix,this._rigCameras[1]._cameraRigParams.vrPreViewMatrix=l.rightPreViewMatrix,this._rigCameras[1].getProjectionMatrix=this._rigCameras[1]._getVRProjectionMatrix,l.compensateDistortion&&(this._rigCameras[0]._rigPostProcess=new e.VRDistortionCorrectionPostProcess("VR_Distort_Compensation_Left",this._rigCameras[0],!1,l),this._rigCameras[1]._rigPostProcess=new e.VRDistortionCorrectionPostProcess("VR_Distort_Compensation_Right",this._rigCameras[1],!0,l));break;case i.RIG_MODE_WEBVR:if(r.vrDisplay){var h=r.vrDisplay.getEyeParameters("left"),u=r.vrDisplay.getEyeParameters("right");this._rigCameras[0].viewport=new e.Viewport(0,0,.5,1),this._rigCameras[0].setCameraRigParameter("left",!0),this._rigCameras[0].setCameraRigParameter("specs",r.specs),this._rigCameras[0].setCameraRigParameter("eyeParameters",h),this._rigCameras[0].setCameraRigParameter("frameData",r.frameData),this._rigCameras[0].setCameraRigParameter("parentCamera",r.parentCamera),this._rigCameras[0]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[0].getProjectionMatrix=this._getWebVRProjectionMatrix,this._rigCameras[0].parent=this,this._rigCameras[0]._getViewMatrix=this._getWebVRViewMatrix,this._rigCameras[1].viewport=new e.Viewport(.5,0,.5,1),this._rigCameras[1].setCameraRigParameter("eyeParameters",u), this._rigCameras[1].setCameraRigParameter("specs",r.specs),this._rigCameras[1].setCameraRigParameter("frameData",r.frameData),this._rigCameras[1].setCameraRigParameter("parentCamera",r.parentCamera),this._rigCameras[1]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[1].getProjectionMatrix=this._getWebVRProjectionMatrix,this._rigCameras[1].parent=this,this._rigCameras[1]._getViewMatrix=this._getWebVRViewMatrix,i.UseAlternateWebVRRendering&&(this._rigCameras[1]._skipRendering=!0,this._rigCameras[0]._alternateCamera=this._rigCameras[1])}}this._cascadePostProcessesToRigCams(),this.update()}},i.prototype._getVRProjectionMatrix=function(){return e.Matrix.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov,this._cameraRigParams.vrMetrics.aspectRatio,this.minZ,this.maxZ,this._cameraRigParams.vrWorkMatrix),this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix,this._projectionMatrix),this._projectionMatrix},i.prototype._updateCameraRotationMatrix=function(){},i.prototype._updateWebVRCameraRotationMatrix=function(){},i.prototype._getWebVRProjectionMatrix=function(){return e.Matrix.Identity()},i.prototype._getWebVRViewMatrix=function(){return e.Matrix.Identity()},i.prototype.setCameraRigParameter=function(t,i){this._cameraRigParams||(this._cameraRigParams={}),this._cameraRigParams[t]=i,"interaxialDistance"===t&&(this._cameraRigParams.stereoHalfAngle=e.Tools.ToRadians(i/.0637))},i.prototype.createRigCamera=function(e,t){return null},i.prototype._updateRigCameras=function(){for(var e=0;ei._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0},t.frontToBackSortCompare=function(e,t){return e._distanceToCamerat._distanceToCamera?1:0},t.prototype.prepare=function(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset(),this._depthOnlySubMeshes.reset(),this._particleSystems.reset(),this._spriteManagers.reset(),this._edgesRenderers.reset()},t.prototype.dispose=function(){this._opaqueSubMeshes.dispose(),this._transparentSubMeshes.dispose(),this._alphaTestSubMeshes.dispose(),this._depthOnlySubMeshes.dispose(),this._particleSystems.dispose(),this._spriteManagers.dispose(),this._edgesRenderers.dispose()},t.prototype.dispatch=function(e){var t=e.getMaterial(),i=e.getMesh();t&&(t.needAlphaBlendingForMesh(i)?this._transparentSubMeshes.push(e):t.needAlphaTesting()?(t.needDepthPrePass&&this._depthOnlySubMeshes.push(e),this._alphaTestSubMeshes.push(e)):(t.needDepthPrePass&&this._depthOnlySubMeshes.push(e),this._opaqueSubMeshes.push(e)),i._edgesRenderer&&this._edgesRenderers.push(i._edgesRenderer))},t.prototype.dispatchSprites=function(e){this._spriteManagers.push(e)},t.prototype.dispatchParticles=function(e){this._particleSystems.push(e)},t.prototype._renderParticles=function(e){if(0!==this._particleSystems.length){var t=this._scene.activeCamera;this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);for(var i=0;ii.LongPressDelay&&Math.abs(n._startingPointerPosition.x-n._pointerX)i.DoubleClickDelay&&!s._doubleClickOccured||e!==s._previousButtonPressed)&&(s._doubleClickOccured=!1,t.singleClick=!0,t.ignore=!1,r(t,s._currentPickResult))},this._initClickEvent=function(r,n,o,a){var l=new t;s._currentPickResult=null;var h=null,u=r.hasSpecificMask(e.PointerEventTypes.POINTERPICK)||n.hasSpecificMask(e.PointerEventTypes.POINTERPICK)||r.hasSpecificMask(e.PointerEventTypes.POINTERTAP)||n.hasSpecificMask(e.PointerEventTypes.POINTERTAP)||r.hasSpecificMask(e.PointerEventTypes.POINTERDOUBLETAP)||n.hasSpecificMask(e.PointerEventTypes.POINTERDOUBLETAP);if(!u&&e.ActionManager&&e.ActionManager.HasPickTriggers&&(h=s._initActionManager(h,l))&&(u=h.hasPickTriggers),u){var c=o.button;if(l.hasSwiped=Math.abs(s._startingPointerPosition.x-s._pointerX)>i.DragMovementThreshold||Math.abs(s._startingPointerPosition.y-s._pointerY)>i.DragMovementThreshold,!l.hasSwiped){var f=!i.ExclusiveDoubleClickMode;f||(f=!r.hasSpecificMask(e.PointerEventTypes.POINTERDOUBLETAP)&&!n.hasSpecificMask(e.PointerEventTypes.POINTERDOUBLETAP))&&!e.ActionManager.HasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)&&(h=s._initActionManager(h,l))&&(f=!h.hasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)),f?((new Date).getTime()-s._previousStartingPointerTime>i.DoubleClickDelay||c!==s._previousButtonPressed)&&(l.singleClick=!0,a(l,s._currentPickResult)):(s._previousDelayedSimpleClickTimeout=s._delayedSimpleClickTimeout,s._delayedSimpleClickTimeout=window.setTimeout(s._delayedSimpleClick.bind(s,c,l,a),i.DoubleClickDelay));var d=r.hasSpecificMask(e.PointerEventTypes.POINTERDOUBLETAP)||n.hasSpecificMask(e.PointerEventTypes.POINTERDOUBLETAP);!d&&e.ActionManager.HasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)&&(h=s._initActionManager(h,l))&&(d=h.hasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)),d&&(c===s._previousButtonPressed&&(new Date).getTime()-s._previousStartingPointerTime0&&(n=s.pickSprite(s._unTranslatedPointerX,s._unTranslatedPointerY,s._spritePredicate,!1,s.cameraToUseForPointers||void 0))&&n.hit&&n.pickedSprite&&n.pickedSprite.actionManager){switch(s._pickedDownSprite=n.pickedSprite,t.button){case 0:n.pickedSprite.actionManager.processTrigger(e.ActionManager.OnLeftPickTrigger,e.ActionEvent.CreateNewFromSprite(n.pickedSprite,s,t));break;case 1:n.pickedSprite.actionManager.processTrigger(e.ActionManager.OnCenterPickTrigger,e.ActionEvent.CreateNewFromSprite(n.pickedSprite,s,t));break;case 2:n.pickedSprite.actionManager.processTrigger(e.ActionManager.OnRightPickTrigger,e.ActionEvent.CreateNewFromSprite(n.pickedSprite,s,t))}n.pickedSprite.actionManager&&n.pickedSprite.actionManager.processTrigger(e.ActionManager.OnPickDownTrigger,e.ActionEvent.CreateNewFromSprite(n.pickedSprite,s,t))}}},this._onPointerUp=function(t){0!==s._totalPointersPressed&&(s._totalPointersPressed--,s._pickedUpMesh=null,s._meshPickProceed=!1,s._updatePointerPosition(t),s._initClickEvent(s.onPrePointerObservable,s.onPointerObservable,t,(function(r,n){if(s.onPrePointerObservable.hasObservers())if(r.ignore){var o=e.PointerEventTypes.POINTERUP,a=new e.PointerInfoPre(o,t,s._unTranslatedPointerX,s._unTranslatedPointerY);if(s.onPrePointerObservable.notifyObservers(a,o),a.skipOnPointerObservable)return}else if(!r.hasSwiped){if(r.singleClick&&s.onPrePointerObservable.hasSpecificMask(e.PointerEventTypes.POINTERTAP)){var o=e.PointerEventTypes.POINTERTAP,a=new e.PointerInfoPre(o,t,s._unTranslatedPointerX,s._unTranslatedPointerY);if(s.onPrePointerObservable.notifyObservers(a,o),a.skipOnPointerObservable)return}if(r.doubleClick&&s.onPrePointerObservable.hasSpecificMask(e.PointerEventTypes.POINTERDOUBLETAP)){var o=e.PointerEventTypes.POINTERDOUBLETAP,a=new e.PointerInfoPre(o,t,s._unTranslatedPointerX,s._unTranslatedPointerY);if(s.onPrePointerObservable.notifyObservers(a,o),a.skipOnPointerObservable)return}}if(s.cameraToUseForPointers||s.activeCamera){if(s.pointerUpPredicate||(s.pointerUpPredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()}),!s._meshPickProceed&&(e.ActionManager&&e.ActionManager.HasTriggers||s.onPointerObservable.hasObservers())&&s._initActionManager(null,r),n||(n=s._currentPickResult),s._processPointerUp(n,t,r),s.spriteManagers.length>0){var l=s.pickSprite(s._unTranslatedPointerX,s._unTranslatedPointerY,s._spritePredicate,!1,s.cameraToUseForPointers||void 0);l&&(l.hit&&l.pickedSprite&&l.pickedSprite.actionManager&&(l.pickedSprite.actionManager.processTrigger(e.ActionManager.OnPickUpTrigger,e.ActionEvent.CreateNewFromSprite(l.pickedSprite,s,t)),l.pickedSprite.actionManager&&Math.abs(s._startingPointerPosition.x-s._pointerX)0)return!1;var t;for(t=0;t0},enumerable:!0,configurable:!0}),i.prototype.executeWhenReady=function(e){var t=this;this.onReadyObservable.add(e),-1===this._executeWhenReadyTimeoutId&&(this._executeWhenReadyTimeoutId=setTimeout((function(){t._checkIsReady()}),150))},i.prototype._checkIsReady=function(){var e=this;if(this.isReady())return this.onReadyObservable.notifyObservers(this),this.onReadyObservable.clear(),void(this._executeWhenReadyTimeoutId=-1);this._executeWhenReadyTimeoutId=setTimeout((function(){e._checkIsReady()}),150)},i.prototype.beginAnimation=function(t,i,r,n,o,s,a){if(void 0===o&&(o=1),i>r&&o>0&&(o*=-1),this.stopAnimation(t),a||(a=new e.Animatable(this,t,i,r,n,o,s)),t.animations&&a.appendAnimations(t,t.animations),t.getAnimatables)for(var l=t.getAnimatables(),h=0;h0)return;this._animationTimeLast=t}var i=(t-this._animationTimeLast)*this.animationTimeScale;this._animationTime+=i,this._animationTimeLast=t;for(var r=0;r0?this.activeCamera=this.cameras[0]:this.activeCamera=null),this.onCameraRemovedObservable.notifyObservers(e),t},i.prototype.addLight=function(e){this.lights.push(e),this.sortLightsByPriority(),this.onNewLightAddedObservable.notifyObservers(e)},i.prototype.sortLightsByPriority=function(){this.requireLightSorting&&this.lights.sort(e.Light.compareLightsPriority)},i.prototype.addCamera=function(e){this.cameras.push(e),this.onNewCameraAddedObservable.notifyObservers(e)},i.prototype.switchActiveCamera=function(e,t){void 0===t&&(t=!0);var i=this._engine.getRenderingCanvas();i&&(this.activeCamera&&this.activeCamera.detachControl(i),this.activeCamera=e,t&&e.attachControl(i))},i.prototype.setActiveCameraByID=function(e){var t=this.getCameraByID(e);return t?(this.activeCamera=t,t):null},i.prototype.setActiveCameraByName=function(e){var t=this.getCameraByName(e);return t?(this.activeCamera=t,t):null},i.prototype.getMaterialByID=function(e){for(var t=0;t-1&&(this._geometries.splice(t,1),this.collisionCoordinator&&this.collisionCoordinator.onGeometryDeleted(e),this.onGeometryRemovedObservable.notifyObservers(e),!0)},i.prototype.getGeometries=function(){return this._geometries},i.prototype.getMeshByID=function(e){for(var t=0;t=0;t--)if(this.meshes[t].id===e)return this.meshes[t];return null},i.prototype.getLastEntryByID=function(e){var t;for(t=this.meshes.length-1;t>=0;t--)if(this.meshes[t].id===e)return this.meshes[t];for(t=this.transformNodes.length-1;t>=0;t--)if(this.transformNodes[t].id===e)return this.transformNodes[t];for(t=this.cameras.length-1;t>=0;t--)if(this.cameras[t].id===e)return this.cameras[t];for(t=this.lights.length-1;t>=0;t--)if(this.lights[t].id===e)return this.lights[t];return null},i.prototype.getNodeByID=function(e){var t=this.getMeshByID(e);if(t)return t;var i=this.getLightByID(e);if(i)return i;var r=this.getCameraByID(e);return r||this.getBoneByID(e)},i.prototype.getNodeByName=function(e){var t=this.getMeshByName(e);if(t)return t;var i=this.getLightByName(e);if(i)return i;var r=this.getCameraByName(e);return r||this.getBoneByName(e)},i.prototype.getMeshByName=function(e){for(var t=0;t=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null},i.prototype.getSkeletonById=function(e){for(var t=0;t0&&0!=(o.layerMask&this.activeCamera.layerMask)&&o.isInFrustum(this._frustumPlanes))&&(this._activeMeshes.push(o),this.activeCamera._activeMeshes.push(o),o._activate(this._renderId),s!==o&&s._activate(this._renderId),this._activeMesh(o,s)))}}if(this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this),this.particlesEnabled){this.onBeforeParticlesRenderingObservable.notifyObservers(this);for(var a=0;a0&&this._renderTargets.concatWithNoDuplicate(t.customRenderTargets),this.renderTargetsEnabled&&this._renderTargets.length>0){this._intermediateRendering=!0,e.Tools.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var s=0;s0),this._intermediateRendering=!1,this._renderId++,o=!0}var h=this._engine.getStencilBuffer(),u=!1;if(this.renderTargetsEnabled&&this.highlightLayers&&this.highlightLayers.length>0){this._intermediateRendering=!0;for(var c=0;c-1)){u=!0;var a=f._mainTexture;a._shouldRender()&&(this._renderId++,a.render(!1,!1),o=!0)}}this._intermediateRendering=!1,this._renderId++}o&&i.restoreDefaultFramebuffer(),this.OnAfterRenderTargetsRenderObservable.notifyObservers(this),this.postProcessManager._prepareFrame();var d,p;if(this.layers.length){for(i.setDepthBuffer(!1),d=0;d0);for(var _=0;_0)}if(this.layers.length){for(i.setDepthBuffer(!1),d=0;d-1&&(n.trigger===e.ActionManager.OnIntersectionExitTrigger&&n._executeCurrent(e.ActionEvent.CreateNew(i,void 0,s)),i.actionManager.hasSpecificTrigger(e.ActionManager.OnIntersectionExitTrigger)&&n.trigger!==e.ActionManager.OnIntersectionExitTrigger||i._intersectionsInProgress.splice(l,1))}}}},i.prototype.render=function(){if(!this.isDisposed){if(this._activeParticles.fetchNewFrame(),this._totalVertices.fetchNewFrame(),this._activeIndices.fetchNewFrame(),this._activeBones.fetchNewFrame(),this._meshesForIntersections.reset(),this.resetCachedMaterial(),this.onBeforeAnimationsObservable.notifyObservers(this),this.actionManager&&this.actionManager.processTrigger(e.ActionManager.OnEveryFrameTrigger),this.simplificationQueue&&!this.simplificationQueue.running&&this.simplificationQueue.executeNext(),this._engine.isDeterministicLockStep()){var t=Math.max(i.MinDeltaTime,Math.min(this._engine.getDeltaTime(),i.MaxDeltaTime))/1e3,r=.06;this._physicsEngine&&(r=this._physicsEngine.getTimeStep());var n=this._engine.getLockstepMaxSteps();this._timeAccumulator+=t;var o=Math.floor(this._timeAccumulator/r);for(o=Math.min(o,n),this._currentInternalStep=0;this._currentInternalStep1&&this._currentInternalStep!=o-1&&this._evaluateActiveMeshes()}else{var t=Math.max(i.MinDeltaTime,Math.min(this._engine.getDeltaTime(),i.MaxDeltaTime));this._animationRatio=.06*t,this._animate(),this.onAfterAnimationsObservable.notifyObservers(this),this._physicsEngine&&(this.onBeforePhysicsObservable.notifyObservers(this),this._physicsEngine._step(t/1e3),this.onAfterPhysicsObservable.notifyObservers(this))}this.onBeforeRenderObservable.notifyObservers(this),this.OnBeforeRenderTargetsRenderObservable.notifyObservers(this);var s=this.getEngine(),a=this.activeCamera;if(this.renderTargetsEnabled){e.Tools.StartPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._intermediateRendering=!0;for(var l=0;l0),this._intermediateRendering=!1,this._renderId++}if(this.customRenderTargets.length>0&&s.restoreDefaultFramebuffer(),this.OnAfterRenderTargetsRenderObservable.notifyObservers(this),this.activeCamera=a,this.proceduralTexturesEnabled){e.Tools.StartPerformanceCounter("Procedural textures",this._proceduralTextures.length>0);for(var u=0;u0)}if((this.autoClearDepthAndStencil||this.autoClear)&&this._engine.clear(this.clearColor,this.autoClear||this.forceWireframe||this.forcePointsCloud,this.autoClearDepthAndStencil,this.autoClearDepthAndStencil),this.shadowsEnabled)for(var f=0;f0)for(var m=0;m0&&this._engine.clear(null,!1,!0,!0),this._processSubCameras(this.activeCameras[m]);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera)}this._checkIntersections(),e.AudioEngine&&this._updateAudioParameters(),this.afterRender&&this.afterRender(),this.onAfterRenderObservable.notifyObservers(this);for(var g=0;g0?this.activeCameras[0]:this.activeCamera)&&i.canUseWebAudio&&i.audioContext){i.audioContext.listener.setPosition(t.position.x,t.position.y,t.position.z),t.rigCameras&&t.rigCameras.length>0&&(t=t.rigCameras[0]);var r=e.Matrix.Invert(t.getViewMatrix()),n=e.Vector3.TransformNormal(new e.Vector3(0,0,-1),r);n.normalize(),isNaN(n.x)||isNaN(n.y)||isNaN(n.z)||i.audioContext.listener.setOrientation(n.x,n.y,n.z,0,1,0);var o;for(o=0;o-1&&this._engine.scenes.splice(i,1),this._engine.wipeCaches(),this._isDisposed=!0},Object.defineProperty(i.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!0,configurable:!0}),i.prototype.disposeSounds=function(){if(this._mainSoundTrack){this.mainSoundTrack.dispose();for(var e=0;e=n.distance))&&(n=h,r)))break}return n||new e.PickingInfo},i.prototype._internalMultiPick=function(t,i){if(!e.PickingInfo)return null;for(var r=new Array,n=0;n0)for(var s=0;s=o.distance))&&(o=l,r))break}}return o||new e.PickingInfo},i.prototype.pick=function(t,i,r,n,o){var s=this;return this._tempPickingRay||(this._tempPickingRay=e.Ray.Zero()),this._internalPick((function(e){return s.createPickingRayToRef(t,i,e,s._tempPickingRay,o||null),s._tempPickingRay}),r,n)},i.prototype.pickSprite=function(t,i,r,n,o){return this._tempPickingRay||(this._tempPickingRay=e.Ray.Zero()),this.createPickingRayInCameraSpaceToRef(t,i,this._tempPickingRay,o),this._internalPickSprites(this._tempPickingRay,r,n,o)},i.prototype.pickWithRay=function(t,i,r){var n=this;return this._internalPick((function(i){return n._pickWithRayInverseMatrix||(n._pickWithRayInverseMatrix=e.Matrix.Identity()),i.invertToRef(n._pickWithRayInverseMatrix),n._cachedRayForTransform||(n._cachedRayForTransform=e.Ray.Zero()),e.Ray.TransformToRef(t,n._pickWithRayInverseMatrix,n._cachedRayForTransform),n._cachedRayForTransform}),i,r)},i.prototype.multiPick=function(e,t,i,r){var n=this;return this._internalMultiPick((function(i){return n.createPickingRay(e,t,i,r||null)}),i)},i.prototype.multiPickWithRay=function(t,i){var r=this;return this._internalMultiPick((function(i){return r._pickWithRayInverseMatrix||(r._pickWithRayInverseMatrix=e.Matrix.Identity()),i.invertToRef(r._pickWithRayInverseMatrix),r._cachedRayForTransform||(r._cachedRayForTransform=e.Ray.Zero()),e.Ray.TransformToRef(t,r._pickWithRayInverseMatrix,r._cachedRayForTransform),r._cachedRayForTransform}),i)},i.prototype.setPointerOverMesh=function(t){this._pointerOverMesh!==t&&(this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.processTrigger(e.ActionManager.OnPointerOutTrigger,e.ActionEvent.CreateNew(this._pointerOverMesh)),this._pointerOverMesh=t,this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.processTrigger(e.ActionManager.OnPointerOverTrigger,e.ActionEvent.CreateNew(this._pointerOverMesh)))},i.prototype.getPointerOverMesh=function(){return this._pointerOverMesh},i.prototype.setPointerOverSprite=function(t){this._pointerOverSprite!==t&&(this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.processTrigger(e.ActionManager.OnPointerOutTrigger,e.ActionEvent.CreateNewFromSprite(this._pointerOverSprite,this)),this._pointerOverSprite=t,this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.processTrigger(e.ActionManager.OnPointerOverTrigger,e.ActionEvent.CreateNewFromSprite(this._pointerOverSprite,this)))},i.prototype.getPointerOverSprite=function(){return this._pointerOverSprite},i.prototype.getPhysicsEngine=function(){return this._physicsEngine},i.prototype.enablePhysics=function(t,i){if(void 0===t&&(t=null),this._physicsEngine)return!0;try{return this._physicsEngine=new e.PhysicsEngine(t,i),!0}catch(t){return e.Tools.Error(t.message),!1}},i.prototype.disablePhysicsEngine=function(){this._physicsEngine&&(this._physicsEngine.dispose(),this._physicsEngine=null)},i.prototype.isPhysicsEnabled=function(){return void 0!==this._physicsEngine},i.prototype.deleteCompoundImpostor=function(e){var t=e.parts[0].mesh;t.physicsImpostor&&(t.physicsImpostor.dispose(),t.physicsImpostor=null)},i.prototype._rebuildGeometries=function(){for(var e=0,t=this._geometries;e=0&&this._scene.textures.splice(e,1),void 0!==this._texture&&(this.releaseInternalTexture(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear())}},t.prototype.serialize=function(){if(!this.name)return null;var t=e.SerializationHelper.Serialize(this);return e.Animation.AppendSerializedAnimations(this,t),t},t.WhenAllReady=function(e,t){var i=e.length;if(0===i)return void t();for(var r,n,o=0;o0},enumerable:!0,configurable:!0}),r.prototype._sortLODLevels=function(){this._LODLevels.sort((function(e,t){return e.distancet.distance?-1:0}))},r.prototype.addLODLevel=function(t,i){if(i&&i._masterMesh)return e.Tools.Warn("You cannot use a mesh as LOD level twice"),this;var r=new e.Internals.MeshLODLevel(t,i);return this._LODLevels.push(r),i&&(i._masterMesh=this),this._sortLODLevels(),this},r.prototype.getLODLevelAtDistance=function(e){for(var t=0;tr)return this.onLODLevelSelection&&this.onLODLevelSelection(r,this,this._LODLevels[this._LODLevels.length-1].mesh),this;for(var n=0;n0){var r=this.getIndices();if(!r)return null;var n=r.length,o=!1;if(t)o=!0;else for(var s=0,a=this.subMeshes;s=n){o=!0;break}if(l.verticesStart+l.verticesCount>=i){o=!0;break}}if(!o)return this.subMeshes[0]}return this.releaseSubMeshes(),new e.SubMesh(0,0,i,0,this.getTotalIndices(),this)},r.prototype.subdivide=function(t){if(!(t<1)){for(var i=this.getTotalIndices(),r=i/t|0,n=0;r%3!=0;)r++;this.releaseSubMeshes();for(var o=0;o=i);o++)e.SubMesh.CreateFromIndices(0,n,Math.min(r,i-n),this),n+=r;this.synchronizeInstances()}},r.prototype.setVerticesData=function(t,i,r,n){if(void 0===r&&(r=!1),this._geometry)this._geometry.setVerticesData(t,i,r,n);else{var o=new e.VertexData;o.set(i,t);var s=this.getScene();new e.Geometry(e.Geometry.RandomId(),s,o,r,this)}return this},r.prototype.markVerticesDataAsUpdatable=function(e,t){void 0===t&&(t=!0);var i=this.getVertexBuffer(e);i&&i.isUpdatable()!==t&&this.setVerticesData(e,this.getVerticesData(e),t)},r.prototype.setVerticesBuffer=function(t){return this._geometry||(this._geometry=e.Geometry.CreateGeometryForMesh(this)),this._geometry.setVerticesBuffer(t),this},r.prototype.updateVerticesData=function(e,t,i,r){return this._geometry?(r?(this.makeGeometryUnique(),this.updateVerticesData(e,t,i,!1)):this._geometry.updateVerticesData(e,t,i),this):this},r.prototype.updateMeshPositions=function(t,i){void 0===i&&(i=!0);var r=this.getVerticesData(e.VertexBuffer.PositionKind);if(!r)return this;if(t(r),this.updateVerticesData(e.VertexBuffer.PositionKind,r,!1,!1),i){var n=this.getIndices(),o=this.getVerticesData(e.VertexBuffer.NormalKind);if(!o)return this;e.VertexData.ComputeNormals(r,n,o),this.updateVerticesData(e.VertexBuffer.NormalKind,o,!1,!1)}return this},r.prototype.makeGeometryUnique=function(){if(!this._geometry)return this;var t=this._geometry,i=this._geometry.copy(e.Geometry.RandomId());return t.releaseForMesh(this,!0),i.applyToMesh(this),this},r.prototype.setIndices=function(t,i,r){if(void 0===i&&(i=null),void 0===r&&(r=!1),this._geometry)this._geometry.setIndices(t,i,r);else{var n=new e.VertexData;n.indices=t;var o=this.getScene();new e.Geometry(e.Geometry.RandomId(),o,n,r,this)}return this},r.prototype.updateIndices=function(e,t){return this._geometry?(this._geometry.updateIndices(e,t),this):this},r.prototype.toLeftHanded=function(){return this._geometry?(this._geometry.toLeftHanded(),this):this},r.prototype._bind=function(t,i,r){if(!this._geometry)return this;var n,o=this.getScene().getEngine();if(this._unIndexed)n=null;else switch(r){case e.Material.PointFillMode:n=null;break;case e.Material.WireFrameFillMode:n=t.getLinesIndexBuffer(this.getIndices(),o);break;default:case e.Material.TriangleFillMode:n=this._unIndexed?null:this._geometry.getIndexBuffer()}return this._geometry._bind(i,n),this},r.prototype._draw=function(t,i,r,n){if(void 0===n&&(n=!1),!this._geometry||!this._geometry.getVertexBuffers()||!this._geometry.getIndexBuffer())return this;this.onBeforeDrawObservable.notifyObservers(this);var o=this.getScene(),s=o.getEngine();switch(i){case e.Material.PointFillMode:s.drawPointClouds(t.verticesStart,t.verticesCount,r);break;case e.Material.WireFrameFillMode:this._unIndexed?s.drawUnIndexed(!1,t.verticesStart,t.verticesCount,r):s.draw(!1,0,t.linesIndexCount,r);break;default:this._unIndexed?s.drawUnIndexed(!0,t.verticesStart,t.verticesCount,r):s.draw(!0,t.indexStart,t.indexCount,r)}if(o._isAlternateRenderingEnabled&&!n){var a=t.effect||this._effectiveMaterial.getEffect();if(!a||!o.activeCamera)return this;o._switchToAlternateCameraConfiguration(!0),this._effectiveMaterial.bindView(a),this._effectiveMaterial.bindViewProjection(a),s.setViewport(o.activeCamera._alternateCamera.viewport),this._draw(t,i,r,!0),s.setViewport(o.activeCamera.viewport),o._switchToAlternateCameraConfiguration(!1),this._effectiveMaterial.bindView(a),this._effectiveMaterial.bindViewProjection(a)}return this},r.prototype.registerBeforeRender=function(e){return this.onBeforeRenderObservable.add(e),this},r.prototype.unregisterBeforeRender=function(e){return this.onBeforeRenderObservable.removeCallback(e),this},r.prototype.registerAfterRender=function(e){return this.onAfterRenderObservable.add(e),this},r.prototype.unregisterAfterRender=function(e){return this.onAfterRenderObservable.removeCallback(e),this},r.prototype._getInstancesRenderList=function(e){var t=this.getScene();if(this._batchCache.mustReturn=!1,this._batchCache.renderSelf[e]=this.isEnabled()&&this.isVisible,this._batchCache.visibleInstances[e]=null,this._visibleInstances){var i=t.getRenderId(),r=t._isInIntermediateRendering()?this._visibleInstances.intermediateDefaultRenderId:this._visibleInstances.defaultRenderId;this._batchCache.visibleInstances[e]=this._visibleInstances[i];var n=this._renderId;!this._batchCache.visibleInstances[e]&&r&&(this._batchCache.visibleInstances[e]=this._visibleInstances[r],i=Math.max(r,i),n=Math.max(this._visibleInstances.selfDefaultRenderId,i));var o=this._batchCache.visibleInstances[e];if(o&&o.length){if(this._renderIdForInstances[e]===i)return this._batchCache.mustReturn=!0,this._batchCache;i!==n&&(this._batchCache.renderSelf[e]=!1)}this._renderIdForInstances[e]=i}return this._batchCache},r.prototype._renderWithInstances=function(t,i,r,n,o){var s=r.visibleInstances[t._id];if(!s)return this;for(var a=s.length+1,l=16*a*4,h=this._instancesBufferSize,u=this._instancesBuffer;this._instancesBufferSize-1;t--)if(i[t].id===e)return this.material=i[t],this;var r=this.getScene().multiMaterials;for(t=r.length-1;t>-1;t--)if(r[t].id===e)return this.material=r[t],this;return this},r.prototype.getAnimatables=function(){var e=new Array;return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e},r.prototype.bakeTransformIntoVertices=function(t){if(!this.isVerticesDataPresent(e.VertexBuffer.PositionKind))return this;var i=this.subMeshes.splice(0);this._resetPointsArrayCache();var r,n=this.getVerticesData(e.VertexBuffer.PositionKind),o=new Array;for(r=0;r-1&&(o.morphTargetManager=i.getMorphTargetManagerById(t.morphTargetManagerId)),t.skeletonId>-1&&(o.skeleton=i.getLastSkeletonByID(t.skeletonId),t.numBoneInfluencers&&(o.numBoneInfluencers=t.numBoneInfluencers)),t.animations){for(var s=0;s4,l=a?this.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind):null,h=a?this.getVerticesData(e.VertexBuffer.MatricesWeightsExtraKind):null;if(!h||!l)return this;for(var u,c=t.getTransformMatrices(this),f=e.Vector3.Zero(),d=new e.Matrix,p=new e.Matrix,_=0,m=0;m0;u++)e.Matrix.FromFloat32ArrayToRefScaled(c,16*o[_+u],g,p),d.addToSelf(p);if(a)for(u=0;u<4&&(g=h[_+u])>0;u++)e.Matrix.FromFloat32ArrayToRefScaled(c,16*l[_+u],g,p),d.addToSelf(p);e.Vector3.TransformCoordinatesFromFloatsToRef(this._sourcePositions[m],this._sourcePositions[m+1],this._sourcePositions[m+2],d,f),f.toArray(r,m),e.Vector3.TransformNormalFromFloatsToRef(this._sourceNormals[m],this._sourceNormals[m+1],this._sourceNormals[m+2],d,f),f.toArray(n,m),d.reset()}return this.updateVerticesData(e.VertexBuffer.PositionKind,r),this.updateVerticesData(e.VertexBuffer.NormalKind,n),this},r.MinMax=function(t){var i=null,r=null;return t.forEach((function(e,t,n){var o=e.getBoundingInfo(),s=o.boundingBox;i&&r?(i.MinimizeInPlace(s.minimumWorld),r.MaximizeInPlace(s.maximumWorld)):(i=s.minimumWorld,r=s.maximumWorld)})),i&&r?{min:i,max:r}:{min:e.Vector3.Zero(),max:e.Vector3.Zero()}},r.Center=function(t){var i=t instanceof Array?e.Mesh.MinMax(t):t;return e.Vector3.Center(i.min,i.max)},r.MergeMeshes=function(t,i,n,o,s){void 0===i&&(i=!0);var a;if(!n){var l=0;for(a=0;a65536)return e.Tools.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),null}var h,u=null,c=new Array,f=null;for(a=0;aa&&(a=u)}return new i(e,s,a-s+1,t,r,n,o)},i})(t);e.SubMesh=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._defines={},this._currentRank=32,this._maxRank=-1}return t.prototype.unBindMesh=function(){this._mesh=null},t.prototype.addFallback=function(e,t){this._defines[e]||(ethis._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)},t.prototype.addCPUSkinningFallback=function(e,t){this._meshRank=e,this._mesh=t,ethis._maxRank&&(this._maxRank=e)},Object.defineProperty(t.prototype,"isMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!0,configurable:!0}),t.prototype.reduce=function(t){if(this._mesh&&this._mesh.computeBonesUsingShaders&&this._mesh.numBoneInfluencers>0){this._mesh.computeBonesUsingShaders=!1,t=t.replace("#define NUM_BONE_INFLUENCERS "+this._mesh.numBoneInfluencers,"#define NUM_BONE_INFLUENCERS 0"),e.Tools.Log("Falling back to CPU skinning for "+this._mesh.name);for(var i=this._mesh.getScene(),r=0;r0&&(n.computeBonesUsingShaders=!1)}}else{var o=this._defines[this._currentRank];if(o)for(var r=0;r-1?i:e.Engine.ShadersRepository+i,e.Tools.LoadFile(n+".vertex.fx",r)},t.prototype._loadFragmentShader=function(i,r){if(e.Tools.IsWindowObjectExist()&&i instanceof HTMLElement){return void r(e.Tools.GetDOMTextContent(i))}if("base64:"===i.substr(0,7)){return void r(window.atob(i.substr(7)))}if(t.ShadersStore[i+"PixelShader"])return void r(t.ShadersStore[i+"PixelShader"]);if(t.ShadersStore[i+"FragmentShader"])return void r(t.ShadersStore[i+"FragmentShader"]);var n;n="."===i[0]||"/"===i[0]||i.indexOf("http")>-1?i:e.Engine.ShadersRepository+i,e.Tools.LoadFile(n+".fragment.fx",r)},t.prototype._dumpShadersSource=function(t,i,r){var n=this._engine.webGLVersion>1?"#version 300 es\n":"",o=n+(r?r+"\n":"");t=o+t,i=o+i;var s=2,a="\n1\t"+t.replace(/\n/gm,(function(){return"\n"+s+++"\t"}));s=2;var l="\n1\t"+i.replace(/\n/gm,(function(){return"\n"+s+++"\t"}));this.name.vertexElement?(e.Tools.Error("Vertex shader: "+this.name.vertexElement+a),e.Tools.Error("Fragment shader: "+this.name.fragmentElement+l)):this.name.vertex?(e.Tools.Error("Vertex shader: "+this.name.vertex+a),e.Tools.Error("Fragment shader: "+this.name.fragment+l)):(e.Tools.Error("Vertex shader: "+this.name+a),e.Tools.Error("Fragment shader: "+this.name+l))},t.prototype._processShaderConversion=function(e,t,i){var r=this._processPrecision(e);if(1==this._engine.webGLVersion)return void i(r);if(-1!==r.indexOf("#version 3"))return void i(r.replace("#version 300 es",""));var n=-1!==r.search(/#extension.+GL_EXT_draw_buffers.+require/),o=r.replace(/#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g,"");o=o.replace(/varying(?![\n\r])\s/g,t?"in ":"out "),o=o.replace(/attribute[ \t]/g,"in "),o=o.replace(/[ \t]attribute/g," in"),t&&(o=o.replace(/texture2DLodEXT\s*\(/g,"textureLod("),o=o.replace(/textureCubeLodEXT\s*\(/g,"textureLod("),o=o.replace(/texture2D\s*\(/g,"texture("),o=o.replace(/textureCube\s*\(/g,"texture("),o=o.replace(/gl_FragDepthEXT/g,"gl_FragDepth"),o=o.replace(/gl_FragColor/g,"glFragColor"),o=o.replace(/gl_FragData/g,"glFragData"),o=o.replace(/void\s+?main\s*\(/g,(n?"":"out vec4 glFragColor;\n")+"void main(")),i(o)},t.prototype._processIncludes=function(i,r){for(var n=this,o=/#include<(.+)>(\((.*)\))*(\[(.*)\])*/g,s=o.exec(i),a=new String(i);null!=s;){var l=s[1];if(-1!==l.indexOf("__decl__")&&(l=l.replace(/__decl__/,""),this._engine.supportsUniformBuffers&&(l=l.replace(/Vertex/,"Ubo"),l=l.replace(/Fragment/,"Ubo")),l+="Declaration"),!t.IncludesShadersStore[l]){var h=e.Engine.ShadersRepository+"ShadersInclude/"+l+".fx";return void e.Tools.LoadFile(h,(function(e){t.IncludesShadersStore[l]=e,n._processIncludes(a,r)}))}var u=t.IncludesShadersStore[l];if(s[2])for(var c=s[3].split(","),f=0;f1)for(var s in this._uniformBuffersNames)this.bindUniformBlock(s,this._uniformBuffersNames[s]);this._uniforms=o.getUniforms(this._program,this._uniformsNames),this._attributes=o.getAttributes(this._program,t);var a;for(a=0;a0,i.NUM_MORPH_INFLUENCERS=l.numInfluencers):(i.MORPHTARGETS_TANGENT=!1,i.MORPHTARGETS_NORMAL=!1,i.MORPHTARGETS=!1,i.NUM_MORPH_INFLUENCERS=0)}return!0},t.PrepareDefinesForLights=function(t,i,r,n,o,s){if(void 0===o&&(o=4),void 0===s&&(s=!1),!r._areLightsDirty)return r._needNormals;var a=0,l=!1,h=!1,u=!1,c=!1,f=!1;if(t.lightsEnabled&&!s)for(var d=0,p=i._lightSources;d0&&(n=r+o,t.addFallback(n,"LIGHT"+o)),e.SHADOWS||(e["SHADOW"+o]&&t.addFallback(r,"SHADOW"+o),e["SHADOWPCF"+o]&&t.addFallback(r,"SHADOWPCF"+o),e["SHADOWESM"+o]&&t.addFallback(r,"SHADOWESM"+o));return n++},t.PrepareAttributesForMorphTargets=function(t,i,r){var n=r.NUM_MORPH_INFLUENCERS;if(n>0&&e.Engine.LastCreatedEngine)for(var o=e.Engine.LastCreatedEngine.getCaps().maxVertexAttribs,s=i.morphTargetManager,a=s&&s.supportsNormals&&r.NORMAL,l=s&&s.supportsTangents&&r.TANGENT,h=0;ho&&e.Tools.Error("Cannot add more vertex attributes for mesh "+i.name)},t.PrepareAttributesForBones=function(t,i,r,n){r.NUM_BONE_INFLUENCERS>0&&(n.addCPUSkinningFallback(0,i),t.push(e.VertexBuffer.MatricesIndicesKind),t.push(e.VertexBuffer.MatricesWeightsKind),r.NUM_BONE_INFLUENCERS>4&&(t.push(e.VertexBuffer.MatricesIndicesExtraKind),t.push(e.VertexBuffer.MatricesWeightsExtraKind)))},t.PrepareAttributesForInstances=function(e,t){t.INSTANCES&&(e.push("world0"),e.push("world1"),e.push("world2"),e.push("world3"))},t.BindLightShadow=function(e,t,i,r,n){if(e.shadowEnabled&&i.receiveShadows){var o=e.getShadowGenerator();o&&o.bindShadowLight(r,n)}},t.BindLightProperties=function(e,t,i){e.transferToEffect(t,i+"")},t.BindLights=function(i,r,n,o,s,a){void 0===s&&(s=4),void 0===a&&(a=!1);for(var l=0,h=0,u=r._lightSources;h=0&&this._scene.materials.splice(i,1),i=0;ia?a:Math.floor(l);var h,u,c,f,d=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,p=i.uvs,_=i.colors,m=[],g=[],v=[],y=[],b=[],x=[],T=[],A=[],E=[],P=[];if(r.length<2){var M=[],S=[];for(c=0;c0&&(D=C[f].subtract(C[f-1]).length(),B=D+T[u],b[u].push(B),T[u]=B),f++;o&&(f--,m.push(C[0].x,C[0].y,C[0].z),D=C[f].subtract(C[0]).length(),B=D+T[u],b[u].push(B),T[u]=B),E[u]=R+I,P[u]=O,O+=R+I}var L,w,F=null,N=null;for(c=0;c1)?1:i.arc||1,l=i.slice&&i.slice<=0?1:i.slice||1,h=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,u=new e.Vector3(n/2,o/2,s/2),c=2+r,f=2*c,d=[],p=[],_=[],m=[],g=0;g<=c;g++){for(var v=g/c,y=v*Math.PI*l,b=0;b<=f;b++){var x=b/f,T=x*Math.PI*2*a,A=e.Matrix.RotationZ(-y),E=e.Matrix.RotationY(T),P=e.Vector3.TransformCoordinates(e.Vector3.Up(),A),M=e.Vector3.TransformCoordinates(P,E),S=M.multiply(u),C=M.divide(u).normalize();p.push(S.x,S.y,S.z),_.push(C.x,C.y,C.z),m.push(x,v)}if(g>0)for(var R=p.length/3,O=R-2*(f+1);O+f+21)?1:i.arc||1,f=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,d=i.faceUV||new Array(3),p=i.faceColors,_=1!==c&&u?2:0,m=h?l:1,g=2+(1+_)*m;for(r=0;r0&&(i.push(o-1),i.push(o)),o++;var h=new t;return h.indices=i,h.positions=r,h},t.CreateDashedLines=function(i){var r=i.dashSize||3,n=i.gapSize||1,o=i.dashNb||200,s=i.points,a=new Array,l=new Array,h=e.Vector3.Zero(),u=0,c=0,f=0,d=0,p=0,_=0,m=0;for(m=0;m1)?1:i.arc||1,u=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE;r.push(0,0,0),s.push(.5,.5);for(var c=2*Math.PI*h,f=c/l,d=0;d=r.length)?0:i.type||0,c=i.size,f=i.sizeX||c||1,d=i.sizeY||c||1,p=i.sizeZ||c||1,_=i.custom||r[u],m=_.face.length,g=i.faceUV||new Array(m),v=i.faceColors,y=void 0===i.flat||i.flat,b=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,x=new Array,T=new Array,A=new Array,E=new Array,P=new Array,M=0,S=0,C=new Array,R=0,O=0;if(y)for(O=0;On.bbSize.y?n.bbSize.x:n.bbSize.y;$=$>n.bbSize.z?$:n.bbSize.z,B=n.subDiv.X*O/n.bbSize.x,L=n.subDiv.Y*O/n.bbSize.y,w=n.subDiv.Z*O/n.bbSize.z,F=n.subDiv.max*n.subDiv.max,n.facetPartitioning.length=0}for(o=0;o0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),this._indexBuffer&&(this._indexBuffer.references=i)},t.prototype.notifyUpdate=function(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e);for(var t=0,i=this._meshes;t0){for(var i=0;i0){for(var i=0;i0){for(var i=0;i0){var l=new Float32Array(i,a.positionsAttrDesc.offset,a.positionsAttrDesc.count);r.setVerticesData(e.VertexBuffer.PositionKind,l,!1)}if(a.normalsAttrDesc&&a.normalsAttrDesc.count>0){var h=new Float32Array(i,a.normalsAttrDesc.offset,a.normalsAttrDesc.count);r.setVerticesData(e.VertexBuffer.NormalKind,h,!1)}if(a.uvsAttrDesc&&a.uvsAttrDesc.count>0){var u=new Float32Array(i,a.uvsAttrDesc.offset,a.uvsAttrDesc.count);r.setVerticesData(e.VertexBuffer.UVKind,u,!1)}if(a.uvs2AttrDesc&&a.uvs2AttrDesc.count>0){var c=new Float32Array(i,a.uvs2AttrDesc.offset,a.uvs2AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV2Kind,c,!1)}if(a.uvs3AttrDesc&&a.uvs3AttrDesc.count>0){var f=new Float32Array(i,a.uvs3AttrDesc.offset,a.uvs3AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV3Kind,f,!1)}if(a.uvs4AttrDesc&&a.uvs4AttrDesc.count>0){var d=new Float32Array(i,a.uvs4AttrDesc.offset,a.uvs4AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV4Kind,d,!1)}if(a.uvs5AttrDesc&&a.uvs5AttrDesc.count>0){var p=new Float32Array(i,a.uvs5AttrDesc.offset,a.uvs5AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV5Kind,p,!1)}if(a.uvs6AttrDesc&&a.uvs6AttrDesc.count>0){var _=new Float32Array(i,a.uvs6AttrDesc.offset,a.uvs6AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV6Kind,_,!1)}if(a.colorsAttrDesc&&a.colorsAttrDesc.count>0){var m=new Float32Array(i,a.colorsAttrDesc.offset,a.colorsAttrDesc.count);r.setVerticesData(e.VertexBuffer.ColorKind,m,!1,a.colorsAttrDesc.stride)}if(a.matricesIndicesAttrDesc&&a.matricesIndicesAttrDesc.count>0){var g=new Int32Array(i,a.matricesIndicesAttrDesc.offset,a.matricesIndicesAttrDesc.count);r.setVerticesData(e.VertexBuffer.MatricesIndicesKind,g,!1)}if(a.matricesWeightsAttrDesc&&a.matricesWeightsAttrDesc.count>0){var v=new Float32Array(i,a.matricesWeightsAttrDesc.offset,a.matricesWeightsAttrDesc.count);r.setVerticesData(e.VertexBuffer.MatricesWeightsKind,v,!1)}if(a.indicesAttrDesc&&a.indicesAttrDesc.count>0){var y=new Int32Array(i,a.indicesAttrDesc.offset,a.indicesAttrDesc.count);r.setIndices(y,null)}if(a.subMeshesAttrDesc&&a.subMeshesAttrDesc.count>0){var b=new Int32Array(i,a.subMeshesAttrDesc.offset,5*a.subMeshesAttrDesc.count);r.subMeshes=[];for(var x=0;x>8),S.push((16711680&C)>>16),S.push(C>>24)}r.setVerticesData(e.VertexBuffer.MatricesIndicesKind,S,i.matricesIndices._updatable)}if(i.matricesIndicesExtra)if(i.matricesIndicesExtra._isExpanded)delete i.matricesIndices._isExpanded,r.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,i.matricesIndicesExtra,i.matricesIndicesExtra._updatable);else{for(var S=[],x=0;x>8),S.push((16711680&C)>>16),S.push(C>>24)}r.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,S,i.matricesIndicesExtra._updatable)}i.matricesWeights&&(t._CleanMatricesWeights(i,r),r.setVerticesData(e.VertexBuffer.MatricesWeightsKind,i.matricesWeights,i.matricesWeights._updatable)),i.matricesWeightsExtra&&r.setVerticesData(e.VertexBuffer.MatricesWeightsExtraKind,i.matricesWeightsExtra,i.matricesWeights._updatable),r.setIndices(i.indices,null)}if(i.subMeshes){r.subMeshes=[];for(var R=0;R-1){var n=i.getScene().getLastSkeletonByID(t.skeletonId);if(n){r=n.bones.length;for(var o=i.getVerticesData(e.VertexBuffer.MatricesIndicesKind),s=i.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind),a=t.matricesWeights,l=t.matricesWeightsExtra,h=t.numBoneInfluencer,u=a.length,c=0;ch-1)&&(d=h-1),f>.001){for(var m=1/f,p=0;p<4;p++)a[c+p]*=m;if(l)for(var p=0;p<4;p++)l[c+p]*=m}else d>=4?(l[c+d-4]=1-f,s[c+d-4]=r):(a[c+d]=1-f,o[c+d]=r)}i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,o),t.matricesWeightsExtra&&i.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,s)}}}},t.Parse=function(i,r,n){if(r.getGeometryByID(i.id))return null;var o=new t(i.id,r,void 0,i.updatable);return e.Tags&&e.Tags.AddTagsTo(o,i.tags),i.delayLoadingFile?(o.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,o.delayLoadingFile=n+i.delayLoadingFile,o._boundingInfo=new e.BoundingInfo(e.Vector3.FromArray(i.boundingBoxMinimum),e.Vector3.FromArray(i.boundingBoxMaximum)),o._delayInfo=[],i.hasUVs&&o._delayInfo.push(e.VertexBuffer.UVKind),i.hasUVs2&&o._delayInfo.push(e.VertexBuffer.UV2Kind),i.hasUVs3&&o._delayInfo.push(e.VertexBuffer.UV3Kind),i.hasUVs4&&o._delayInfo.push(e.VertexBuffer.UV4Kind),i.hasUVs5&&o._delayInfo.push(e.VertexBuffer.UV5Kind),i.hasUVs6&&o._delayInfo.push(e.VertexBuffer.UV6Kind),i.hasColors&&o._delayInfo.push(e.VertexBuffer.ColorKind),i.hasMatricesIndices&&o._delayInfo.push(e.VertexBuffer.MatricesIndicesKind),i.hasMatricesWeights&&o._delayInfo.push(e.VertexBuffer.MatricesWeightsKind),o._delayLoadingFunction=e.VertexData.ImportVertexData):e.VertexData.ImportVertexData(i,o),r.pushGeometry(o,!0),o},t})();e.Geometry=t,(function(t){!(function(i){var r=(function(e){function t(t,i,r,n){void 0===r&&(r=!1),void 0===n&&(n=null);var o=e.call(this,t,i,void 0,!1,n)||this;return o._canBeRegenerated=r,o._beingRegenerated=!0,o.regenerate(),o._beingRegenerated=!1,o}return __extends(t,e),t.prototype.canBeRegenerated=function(){return this._canBeRegenerated},t.prototype.regenerate=function(){this._canBeRegenerated&&(this._beingRegenerated=!0,this.setAllVerticesData(this._regenerateVertexData(),!1),this._beingRegenerated=!1)},t.prototype.asNewGeometry=function(t){return e.prototype.copy.call(this,t)},t.prototype.setAllVerticesData=function(t,i){this._beingRegenerated&&e.prototype.setAllVerticesData.call(this,t,!1)},t.prototype.setVerticesData=function(t,i,r){this._beingRegenerated&&e.prototype.setVerticesData.call(this,t,i,!1)},t.prototype._regenerateVertexData=function(){throw new Error("Abstract method")},t.prototype.copy=function(e){throw new Error("Must be overriden in sub-classes.")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.canBeRegenerated=this.canBeRegenerated(),t},t})(t);i._Primitive=r;var n=(function(t){function i(i,r,n,o,s,a,l,h,u){void 0===u&&(u=e.Mesh.DEFAULTSIDE);var c=t.call(this,i,r,l,h)||this;return c.pathArray=n,c.closeArray=o,c.closePath=s,c.offset=a,c.side=u,c}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateRibbon({pathArray:this.pathArray,closeArray:this.closeArray,closePath:this.closePath,offset:this.offset,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.pathArray,this.closeArray,this.closePath,this.offset,this.canBeRegenerated(),void 0,this.side)},i})(r);i.Ribbon=n;var o=(function(i){function r(t,r,n,o,s,a){void 0===s&&(s=null),void 0===a&&(a=e.Mesh.DEFAULTSIDE);var l=i.call(this,t,r,o,s)||this;return l.size=n,l.side=a,l}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateBox({size:this.size,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.size,this.canBeRegenerated(),void 0,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.size=this.size,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Box(i.id,r,i.size,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Box=o;var s=(function(i){function r(t,r,n,o,s,a,l){void 0===a&&(a=null),void 0===l&&(l=e.Mesh.DEFAULTSIDE);var h=i.call(this,t,r,s,a)||this;return h.segments=n,h.diameter=o,h.side=l,h}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateSphere({segments:this.segments,diameter:this.diameter,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.segments,this.diameter,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.segments=this.segments,e.diameter=this.diameter,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Sphere(i.id,r,i.segments,i.diameter,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Sphere=s;var a=(function(t){function i(i,r,n,o,s,a,l){void 0===a&&(a=null),void 0===l&&(l=e.Mesh.DEFAULTSIDE);var h=t.call(this,i,r,s,a)||this;return h.radius=n,h.tessellation=o,h.side=l,h}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateDisc({radius:this.radius,tessellation:this.tessellation,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.radius,this.tessellation,this.canBeRegenerated(),null,this.side)},i})(r);i.Disc=a;var l=(function(i){function r(t,r,n,o,s,a,l,h,u,c){void 0===l&&(l=1),void 0===u&&(u=null),void 0===c&&(c=e.Mesh.DEFAULTSIDE);var f=i.call(this,t,r,h,u)||this;return f.height=n,f.diameterTop=o,f.diameterBottom=s,f.tessellation=a,f.subdivisions=l,f.side=c,f}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateCylinder({height:this.height,diameterTop:this.diameterTop,diameterBottom:this.diameterBottom,tessellation:this.tessellation,subdivisions:this.subdivisions,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.height,this.diameterTop,this.diameterBottom,this.tessellation,this.subdivisions,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.height=this.height,e.diameterTop=this.diameterTop,e.diameterBottom=this.diameterBottom,e.tessellation=this.tessellation,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Cylinder(i.id,r,i.height,i.diameterTop,i.diameterBottom,i.tessellation,i.subdivisions,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Cylinder=l;var h=(function(i){function r(t,r,n,o,s,a,l,h){void 0===l&&(l=null),void 0===h&&(h=e.Mesh.DEFAULTSIDE);var u=i.call(this,t,r,a,l)||this;return u.diameter=n,u.thickness=o,u.tessellation=s,u.side=h,u}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateTorus({diameter:this.diameter,thickness:this.thickness,tessellation:this.tessellation,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.diameter,this.thickness,this.tessellation,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.diameter=this.diameter,e.thickness=this.thickness,e.tessellation=this.tessellation,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Torus(i.id,r,i.diameter,i.thickness,i.tessellation,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Torus=h;var u=(function(i){function r(e,t,r,n,o,s,a){void 0===a&&(a=null);var l=i.call(this,e,t,s,a)||this;return l.width=r,l.height=n,l.subdivisions=o,l}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateGround({width:this.width,height:this.height,subdivisions:this.subdivisions})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.width,this.height,this.subdivisions,this.canBeRegenerated(),null)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.width=this.width,e.height=this.height,e.subdivisions=this.subdivisions,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Ground(i.id,r,i.width,i.height,i.subdivisions,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Ground=u;var c=(function(t){function i(e,i,r,n,o,s,a,l,h,u){void 0===u&&(u=null);var c=t.call(this,e,i,h,u)||this;return c.xmin=r,c.zmin=n,c.xmax=o,c.zmax=s,c.subdivisions=a,c.precision=l,c}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateTiledGround({xmin:this.xmin,zmin:this.zmin,xmax:this.xmax,zmax:this.zmax,subdivisions:this.subdivisions,precision:this.precision})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.xmin,this.zmin,this.xmax,this.zmax,this.subdivisions,this.precision,this.canBeRegenerated(),null)},i})(r);i.TiledGround=c;var f=(function(i){function r(t,r,n,o,s,a){void 0===s&&(s=null),void 0===a&&(a=e.Mesh.DEFAULTSIDE);var l=i.call(this,t,r,o,s)||this;return l.size=n,l.side=a,l}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreatePlane({size:this.size,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.size,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.size=this.size,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Plane(i.id,r,i.size,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Plane=f;var d=(function(i){function r(t,r,n,o,s,a,l,h,u,c,f){void 0===c&&(c=null),void 0===f&&(f=e.Mesh.DEFAULTSIDE);var d=i.call(this,t,r,u,c)||this;return d.radius=n,d.tube=o,d.radialSegments=s,d.tubularSegments=a,d.p=l,d.q=h,d.side=f,d}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateTorusKnot({radius:this.radius,tube:this.tube,radialSegments:this.radialSegments,tubularSegments:this.tubularSegments,p:this.p,q:this.q,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.radius,this.tube,this.radialSegments,this.tubularSegments,this.p,this.q,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.radius=this.radius,e.tube=this.tube,e.radialSegments=this.radialSegments,e.tubularSegments=this.tubularSegments,e.p=this.p,e.q=this.q,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.TorusKnot(i.id,r,i.radius,i.tube,i.radialSegments,i.tubularSegments,i.p,i.q,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.TorusKnot=d})(t.Primitives||(t.Primitives={}))})(t=e.Geometry||(e.Geometry={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this._vertexBuffers={},this._scene=e}return t.prototype._prepareBuffers=function(){if(!this._vertexBuffers[e.VertexBuffer.PositionKind]){var t=[];t.push(1,1),t.push(-1,1),t.push(-1,-1),t.push(1,-1),this._vertexBuffers[e.VertexBuffer.PositionKind]=new e.VertexBuffer(this._scene.getEngine(),t,e.VertexBuffer.PositionKind,!1,!1,2),this._buildIndexBuffer()}},t.prototype._buildIndexBuffer=function(){var e=[];e.push(0),e.push(1),e.push(2),e.push(0),e.push(2),e.push(3),this._indexBuffer=this._scene.getEngine().createIndexBuffer(e)},t.prototype._rebuild=function(){var t=this._vertexBuffers[e.VertexBuffer.PositionKind];t&&(t._rebuild(),this._buildIndexBuffer())},t.prototype._prepareFrame=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null);var i=this._scene.activeCamera;if(!i)return!1;var t=t||i._postProcesses;return!(!t||0===t.length||!this._scene.postProcessesEnabled)&&(t[0].activate(i,e,null!==t&&void 0!==t),!0)},t.prototype.directRender=function(e,t,i){if(void 0===t&&(t=null),void 0===i&&(i=!1),this._scene.activeCamera){for(var r=this._scene.getEngine(),n=0;n=this._sampleCount||e>=this._samples.length)return 0;var t=this._wrapPosition(this._pos-1);return this._samples[this._wrapPosition(t-e)]},e.prototype.isSaturated=function(){return this._sampleCount>=this._samples.length},e.prototype.reset=function(){this.average=0,this.variance=0,this._sampleCount=0,this._pos=0,this._m2=0},e.prototype._wrapPosition=function(e){var t=this._samples.length;return(e%t+t)%t},e})();e.RollingAverage=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this.colorCurves=new e.ColorCurves,this._colorCurvesEnabled=!1,this._colorGradingEnabled=!1,this._colorGradingWithGreenDepth=!0,this._colorGradingBGR=!0,this._exposure=1,this._toneMappingEnabled=!1,this._contrast=1,this.vignetteStretch=0,this.vignetteCentreX=0,this.vignetteCentreY=0,this.vignetteWeight=1.5,this.vignetteColor=new e.Color4(0,0,0,0),this.vignetteCameraFov=.5,this._vignetteBlendMode=t.VIGNETTEMODE_MULTIPLY,this._vignetteEnabled=!1,this._applyByPostProcess=!1,this.onUpdateParameters=new e.Observable}return Object.defineProperty(t.prototype,"colorCurvesEnabled",{get:function(){return this._colorCurvesEnabled},set:function(e){this._colorCurvesEnabled!==e&&(this._colorCurvesEnabled=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"colorGradingEnabled",{get:function(){return this._colorGradingEnabled},set:function(e){this._colorGradingEnabled!==e&&(this._colorGradingEnabled=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"colorGradingWithGreenDepth",{get:function(){return this._colorGradingWithGreenDepth},set:function(e){this._colorGradingWithGreenDepth!==e&&(this._colorGradingWithGreenDepth=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"colorGradingBGR",{get:function(){return this._colorGradingBGR},set:function(e){this._colorGradingBGR!==e&&(this._colorGradingBGR=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"exposure",{get:function(){return this._exposure},set:function(e){this._exposure!==e&&(this._exposure=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"toneMappingEnabled",{get:function(){return this._toneMappingEnabled},set:function(e){this._toneMappingEnabled!==e&&(this._toneMappingEnabled=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"contrast",{get:function(){return this._contrast},set:function(e){this._contrast!==e&&(this._contrast=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteBlendMode",{get:function(){return this._vignetteBlendMode},set:function(e){this._vignetteBlendMode!==e&&(this._vignetteBlendMode=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteEnabled",{get:function(){return this._vignetteEnabled},set:function(e){this._vignetteEnabled!==e&&(this._vignetteEnabled=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"applyByPostProcess",{get:function(){return this._applyByPostProcess},set:function(e){this._applyByPostProcess!==e&&(this._applyByPostProcess=e,this._updateParameters())},enumerable:!0,configurable:!0}),t.prototype._updateParameters=function(){this.onUpdateParameters.notifyObservers(this)},t.prototype.getClassName=function(){return"ImageProcessingConfiguration"},t.PrepareUniforms=function(t,i){i.EXPOSURE&&t.push("exposureLinear"),i.CONTRAST&&t.push("contrast"),i.COLORGRADING&&t.push("colorTransformSettings"),i.VIGNETTE&&(t.push("vInverseScreenSize"),t.push("vignetteSettings1"),t.push("vignetteSettings2")),i.COLORCURVES&&e.ColorCurves.PrepareUniforms(t)},t.PrepareSamplers=function(e,t){t.COLORGRADING&&e.push("txColorTransform")},t.prototype.prepareDefines=function(e,i){if(void 0===i&&(i=!1),i!==this.applyByPostProcess)return e.VIGNETTE=!1,e.TONEMAPPING=!1,e.CONTRAST=!1,e.EXPOSURE=!1,e.COLORCURVES=!1,e.COLORGRADING=!1,e.COLORGRADING3D=!1,e.IMAGEPROCESSING=!1,void(e.IMAGEPROCESSINGPOSTPROCESS=this.applyByPostProcess);e.VIGNETTE=this.vignetteEnabled,e.VIGNETTEBLENDMODEMULTIPLY=this.vignetteBlendMode===t._VIGNETTEMODE_MULTIPLY,e.VIGNETTEBLENDMODEOPAQUE=!e.VIGNETTEBLENDMODEMULTIPLY,e.TONEMAPPING=this.toneMappingEnabled,e.CONTRAST=1!==this.contrast,e.EXPOSURE=1!==this.exposure,e.COLORCURVES=this.colorCurvesEnabled&&!!this.colorCurves,e.COLORGRADING=this.colorGradingEnabled&&!!this.colorGradingTexture,e.COLORGRADING?e.COLORGRADING3D=this.colorGradingTexture.is3D:e.COLORGRADING3D=!1,e.SAMPLER3DGREENDEPTH=this.colorGradingWithGreenDepth,e.SAMPLER3DBGRMAP=this.colorGradingBGR,e.IMAGEPROCESSINGPOSTPROCESS=this.applyByPostProcess, e.IMAGEPROCESSING=e.VIGNETTE||e.TONEMAPPING||e.CONTRAST||e.EXPOSURE||e.COLORCURVES||e.COLORGRADING},t.prototype.isReady=function(){return!this.colorGradingEnabled||!this.colorGradingTexture||this.colorGradingTexture.isReady()},t.prototype.bind=function(t,i){if(void 0===i&&(i=1),this._colorCurvesEnabled&&this.colorCurves&&e.ColorCurves.Bind(this.colorCurves,t),this._vignetteEnabled){var r=1/t.getEngine().getRenderWidth(),n=1/t.getEngine().getRenderHeight();t.setFloat2("vInverseScreenSize",r,n);var o=Math.tan(.5*this.vignetteCameraFov),s=o*i,a=Math.sqrt(s*o);s=e.Tools.Mix(s,a,this.vignetteStretch),o=e.Tools.Mix(o,a,this.vignetteStretch),t.setFloat4("vignetteSettings1",s,o,-s*this.vignetteCentreX,-o*this.vignetteCentreY);var l=-2*this.vignetteWeight;t.setFloat4("vignetteSettings2",this.vignetteColor.r,this.vignetteColor.g,this.vignetteColor.b,l)}if(t.setFloat("exposureLinear",this.exposure),t.setFloat("contrast",this.contrast),this.colorGradingTexture){t.setTexture("txColorTransform",this.colorGradingTexture);var h=this.colorGradingTexture.getSize().height;t.setFloat4("colorTransformSettings",(h-1)/h,.5/h,h,this.colorGradingTexture.level)}},t.prototype.clone=function(){return e.SerializationHelper.Clone((function(){return new t}),this)},t.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},t.Parse=function(i){return e.SerializationHelper.Parse((function(){return new t}),i,null,null)},Object.defineProperty(t,"VIGNETTEMODE_MULTIPLY",{get:function(){return this._VIGNETTEMODE_MULTIPLY},enumerable:!0,configurable:!0}),Object.defineProperty(t,"VIGNETTEMODE_OPAQUE",{get:function(){return this._VIGNETTEMODE_OPAQUE},enumerable:!0,configurable:!0}),t._VIGNETTEMODE_MULTIPLY=0,t._VIGNETTEMODE_OPAQUE=1,__decorate([e.serializeAsColorCurves()],t.prototype,"colorCurves",void 0),__decorate([e.serialize()],t.prototype,"_colorCurvesEnabled",void 0),__decorate([e.serializeAsTexture()],t.prototype,"colorGradingTexture",void 0),__decorate([e.serialize()],t.prototype,"_colorGradingEnabled",void 0),__decorate([e.serialize()],t.prototype,"_colorGradingWithGreenDepth",void 0),__decorate([e.serialize()],t.prototype,"_colorGradingBGR",void 0),__decorate([e.serialize()],t.prototype,"_exposure",void 0),__decorate([e.serialize()],t.prototype,"_toneMappingEnabled",void 0),__decorate([e.serialize()],t.prototype,"_contrast",void 0),__decorate([e.serialize()],t.prototype,"vignetteStretch",void 0),__decorate([e.serialize()],t.prototype,"vignetteCentreX",void 0),__decorate([e.serialize()],t.prototype,"vignetteCentreY",void 0),__decorate([e.serialize()],t.prototype,"vignetteWeight",void 0),__decorate([e.serializeAsColor4()],t.prototype,"vignetteColor",void 0),__decorate([e.serialize()],t.prototype,"vignetteCameraFov",void 0),__decorate([e.serialize()],t.prototype,"_vignetteBlendMode",void 0),__decorate([e.serialize()],t.prototype,"_vignetteEnabled",void 0),__decorate([e.serialize()],t.prototype,"_applyByPostProcess",void 0),t})();e.ImageProcessingConfiguration=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r){var n=t.call(this,r)||this;return i?(n._engine=r.getEngine(),n._textureMatrix=e.Matrix.Identity(),n.name=i,n.url=i,n.hasAlpha=!1,n.isCube=!1,n.is3D=n._engine.webGLVersion>1,n.wrapU=e.Texture.CLAMP_ADDRESSMODE,n.wrapV=e.Texture.CLAMP_ADDRESSMODE,n.wrapR=e.Texture.CLAMP_ADDRESSMODE,n.anisotropicFilteringLevel=1,n._texture=n._getFromCache(i,!0),n._texture||(r.useDelayedTextureLoading?n.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED:n.loadTexture()),n):n}return __extends(i,t),i.prototype.getTextureMatrix=function(){return this._textureMatrix},i.prototype.load3dlTexture=function(){var t,r=this._engine;t=1===r.webGLVersion?r.createRawTexture(null,1,1,e.Engine.TEXTUREFORMAT_RGBA,!1,!1,e.Texture.BILINEAR_SAMPLINGMODE):r.createRawTexture3D(null,1,1,1,e.Engine.TEXTUREFORMAT_RGBA,!1,!1,e.Texture.BILINEAR_SAMPLINGMODE),this._texture=t;var n=function(n){for(var o,s=null,a=null,l=n.split("\n"),h=0,u=0,c=0,f=0,d=0,p=0;p0&&(p+1)%4==0)s[p]=255;else{var b=a[p];s[p]=b/d*255}t.is3D?(t.updateSize(h,h,h),r.updateRawTexture3D(t,s,e.Engine.TEXTUREFORMAT_RGBA,!1)):(t.updateSize(h*h,h),r.updateRawTexture(t,s,e.Engine.TEXTUREFORMAT_RGBA,!1))};return e.Tools.LoadFile(this.url,n),this._texture},i.prototype.loadTexture=function(){this.url&&this.url.toLocaleLowerCase().indexOf(".3dl")==this.url.length-4&&this.load3dlTexture()},i.prototype.clone=function(){var e=new i(this.url,this.getScene());return e.level=this.level,e},i.prototype.delayLoad=function(){this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,!0),this._texture||this.loadTexture())},i.Parse=function(t,i,r){var n=null;return t.name&&!t.isRenderTarget&&(n=new e.ColorGradingTexture(t.name,i),n.name=t.name,n.level=t.level),n},i.prototype.serialize=function(){if(!this.name)return null;var e={};return e.name=this.name,e.level=this.level,e.customType="BABYLON.ColorGradingTexture",e},i._noneEmptyLineRegex=/\S+/,i})(e.BaseTexture);e.ColorGradingTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._dirty=!0,this._tempColor=new e.Color4(0,0,0,0),this._globalCurve=new e.Color4(0,0,0,0),this._highlightsCurve=new e.Color4(0,0,0,0),this._midtonesCurve=new e.Color4(0,0,0,0),this._shadowsCurve=new e.Color4(0,0,0,0),this._positiveCurve=new e.Color4(0,0,0,0),this._negativeCurve=new e.Color4(0,0,0,0),this._globalHue=30,this._globalDensity=0,this._globalSaturation=0,this._globalExposure=0,this._highlightsHue=30,this._highlightsDensity=0,this._highlightsSaturation=0,this._highlightsExposure=0,this._midtonesHue=30,this._midtonesDensity=0,this._midtonesSaturation=0,this._midtonesExposure=0,this._shadowsHue=30,this._shadowsDensity=0,this._shadowsSaturation=0,this._shadowsExposure=0}return Object.defineProperty(t.prototype,"globalHue",{get:function(){return this._globalHue},set:function(e){this._globalHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"globalDensity",{get:function(){return this._globalDensity},set:function(e){this._globalDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"globalSaturation",{get:function(){return this._globalSaturation},set:function(e){this._globalSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsHue",{get:function(){return this._highlightsHue},set:function(e){this._highlightsHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsDensity",{get:function(){return this._highlightsDensity},set:function(e){this._highlightsDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsSaturation",{get:function(){return this._highlightsSaturation},set:function(e){this._highlightsSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsExposure",{get:function(){return this._highlightsExposure},set:function(e){this._highlightsExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesHue",{get:function(){return this._midtonesHue},set:function(e){this._midtonesHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesDensity",{get:function(){return this._midtonesDensity},set:function(e){this._midtonesDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesSaturation",{get:function(){return this._midtonesSaturation},set:function(e){this._midtonesSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesExposure",{get:function(){return this._midtonesExposure},set:function(e){this._midtonesExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsHue",{get:function(){return this._shadowsHue},set:function(e){this._shadowsHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsDensity",{get:function(){return this._shadowsDensity},set:function(e){this._shadowsDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsSaturation",{get:function(){return this._shadowsSaturation},set:function(e){this._shadowsSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsExposure",{get:function(){return this._shadowsExposure},set:function(e){this._shadowsExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"ColorCurves"},t.Bind=function(e,t,i,r,n){void 0===i&&(i="vCameraColorCurvePositive"),void 0===r&&(r="vCameraColorCurveNeutral"),void 0===n&&(n="vCameraColorCurveNegative"),e._dirty&&(e._dirty=!1,e.getColorGradingDataToRef(e._globalHue,e._globalDensity,e._globalSaturation,e._globalExposure,e._globalCurve),e.getColorGradingDataToRef(e._highlightsHue,e._highlightsDensity,e._highlightsSaturation,e._highlightsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._highlightsCurve),e.getColorGradingDataToRef(e._midtonesHue,e._midtonesDensity,e._midtonesSaturation,e._midtonesExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._midtonesCurve),e.getColorGradingDataToRef(e._shadowsHue,e._shadowsDensity,e._shadowsSaturation,e._shadowsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._shadowsCurve),e._highlightsCurve.subtractToRef(e._midtonesCurve,e._positiveCurve),e._midtonesCurve.subtractToRef(e._shadowsCurve,e._negativeCurve)),t&&(t.setFloat4(i,e._positiveCurve.r,e._positiveCurve.g,e._positiveCurve.b,e._positiveCurve.a),t.setFloat4(r,e._midtonesCurve.r,e._midtonesCurve.g,e._midtonesCurve.b,e._midtonesCurve.a),t.setFloat4(n,e._negativeCurve.r,e._negativeCurve.g,e._negativeCurve.b,e._negativeCurve.a))},t.PrepareUniforms=function(e){e.push("vCameraColorCurveNeutral","vCameraColorCurvePositive","vCameraColorCurveNegative")},t.prototype.getColorGradingDataToRef=function(e,i,r,n,o){null!=e&&(e=t.clamp(e,0,360),i=t.clamp(i,-100,100),r=t.clamp(r,-100,100),n=t.clamp(n,-100,100),i=t.applyColorGradingSliderNonlinear(i),i*=.5,n=t.applyColorGradingSliderNonlinear(n),i<0&&(i*=-1,e=(e+180)%360),t.fromHSBToRef(e,i,50+.25*n,o),o.scaleToRef(2,o),o.a=1+.01*r)},t.applyColorGradingSliderNonlinear=function(e){e/=100;var t=Math.abs(e);return t=Math.pow(t,2),e<0&&(t*=-1),t*=100},t.fromHSBToRef=function(e,i,r,n){var o=t.clamp(e,0,360),s=t.clamp(i/100,0,1),a=t.clamp(r/100,0,1);if(0===s)n.r=a,n.g=a,n.b=a;else{o/=60;var l=Math.floor(o),h=o-l,u=a*(1-s),c=a*(1-s*h),f=a*(1-s*(1-h));switch(l){case 0:n.r=a,n.g=f,n.b=u;break;case 1:n.r=c,n.g=a,n.b=u;break;case 2:n.r=u,n.g=a,n.b=f;break;case 3:n.r=u,n.g=c,n.b=a;break;case 4:n.r=f,n.g=u,n.b=a;break;default:n.r=a,n.g=u,n.b=c}}n.a=1},t.clamp=function(e,t,i){return Math.min(Math.max(e,t),i)},t.prototype.clone=function(){return e.SerializationHelper.Clone((function(){return new t}),this)},t.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},t.Parse=function(i){return e.SerializationHelper.Parse((function(){return new t}),i,null,null)},__decorate([e.serialize()],t.prototype,"_globalHue",void 0),__decorate([e.serialize()],t.prototype,"_globalDensity",void 0),__decorate([e.serialize()],t.prototype,"_globalSaturation",void 0),__decorate([e.serialize()],t.prototype,"_globalExposure",void 0),__decorate([e.serialize()],t.prototype,"_highlightsHue",void 0),__decorate([e.serialize()],t.prototype,"_highlightsDensity",void 0),__decorate([e.serialize()],t.prototype,"_highlightsSaturation",void 0),__decorate([e.serialize()],t.prototype,"_highlightsExposure",void 0),__decorate([e.serialize()],t.prototype,"_midtonesHue",void 0),__decorate([e.serialize()],t.prototype,"_midtonesDensity",void 0),__decorate([e.serialize()],t.prototype,"_midtonesSaturation",void 0),__decorate([e.serialize()],t.prototype,"_midtonesExposure",void 0),t})();e.ColorCurves=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(){var t=e.call(this)||this;return t.MAINUV1=!1,t.MAINUV2=!1,t.DIFFUSE=!1,t.DIFFUSEDIRECTUV=0,t.AMBIENT=!1,t.AMBIENTDIRECTUV=0,t.OPACITY=!1,t.OPACITYDIRECTUV=0,t.OPACITYRGB=!1,t.REFLECTION=!1,t.EMISSIVE=!1,t.EMISSIVEDIRECTUV=0,t.SPECULAR=!1,t.SPECULARDIRECTUV=0,t.BUMP=!1,t.BUMPDIRECTUV=0,t.PARALLAX=!1,t.PARALLAXOCCLUSION=!1,t.SPECULAROVERALPHA=!1,t.CLIPPLANE=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!1,t.ALPHAFROMDIFFUSE=!1,t.POINTSIZE=!1,t.FOG=!1,t.SPECULARTERM=!1,t.DIFFUSEFRESNEL=!1,t.OPACITYFRESNEL=!1,t.REFLECTIONFRESNEL=!1,t.REFRACTIONFRESNEL=!1,t.EMISSIVEFRESNEL=!1,t.FRESNEL=!1,t.NORMAL=!1,t.UV1=!1,t.UV2=!1,t.VERTEXCOLOR=!1,t.VERTEXALPHA=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.INSTANCES=!1,t.GLOSSINESS=!1,t.ROUGHNESS=!1,t.EMISSIVEASILLUMINATION=!1,t.LINKEMISSIVEWITHDIFFUSE=!1,t.REFLECTIONFRESNELFROMSPECULAR=!1,t.LIGHTMAP=!1,t.LIGHTMAPDIRECTUV=0,t.USELIGHTMAPASSHADOWMAP=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.LOGARITHMICDEPTH=!1,t.REFRACTION=!1,t.REFRACTIONMAP_3D=!1,t.REFLECTIONOVERALPHA=!1,t.TWOSIDEDLIGHTING=!1,t.SHADOWFLOAT=!1,t.MORPHTARGETS=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS_TANGENT=!1,t.NUM_MORPH_INFLUENCERS=0,t.NONUNIFORMSCALING=!1,t.PREMULTIPLYALPHA=!1,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.COLORGRADING3D=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.EXPOSURE=!1,t.rebuild(),t}return __extends(t,e),t.prototype.setReflectionMode=function(e){for(var t=["REFLECTIONMAP_CUBIC","REFLECTIONMAP_EXPLICIT","REFLECTIONMAP_PLANAR","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_SKYBOX","REFLECTIONMAP_SPHERICAL","REFLECTIONMAP_EQUIRECTANGULAR","REFLECTIONMAP_EQUIRECTANGULAR_FIXED","REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"],i=0,r=t;i0,a.REFLECTIONOVERALPHA=this._useReflectionOverAlpha,a.INVERTCUBICMAP=this._reflectionTexture.coordinatesMode===e.Texture.INVCUBIC_MODE,a.REFLECTIONMAP_3D=this._reflectionTexture.isCube,this._reflectionTexture.coordinatesMode){case e.Texture.CUBIC_MODE:case e.Texture.INVCUBIC_MODE:a.setReflectionMode("REFLECTIONMAP_CUBIC");break;case e.Texture.EXPLICIT_MODE:a.setReflectionMode("REFLECTIONMAP_EXPLICIT");break;case e.Texture.PLANAR_MODE:a.setReflectionMode("REFLECTIONMAP_PLANAR");break;case e.Texture.PROJECTION_MODE:a.setReflectionMode("REFLECTIONMAP_PROJECTION");break;case e.Texture.SKYBOX_MODE:a.setReflectionMode("REFLECTIONMAP_SKYBOX");break;case e.Texture.SPHERICAL_MODE:a.setReflectionMode("REFLECTIONMAP_SPHERICAL");break;case e.Texture.EQUIRECTANGULAR_MODE:a.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");break;case e.Texture.FIXED_EQUIRECTANGULAR_MODE:a.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");break;case e.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:a.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED")}}else a.REFLECTION=!1;if(this._emissiveTexture&&r.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._emissiveTexture,a,"EMISSIVE")}else a.EMISSIVE=!1;if(this._lightmapTexture&&r.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._lightmapTexture,a,"LIGHTMAP"),a.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap}else a.LIGHTMAP=!1;if(this._specularTexture&&r.SpecularTextureEnabled){if(!this._specularTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._specularTexture,a,"SPECULAR"),a.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha}else a.SPECULAR=!1;if(s.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&r.BumpTextureEnabled){if(!this._bumpTexture.isReady())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._bumpTexture,a,"BUMP"),a.PARALLAX=this._useParallax,a.PARALLAXOCCLUSION=this._useParallaxOcclusion}else a.BUMP=!1;if(this._refractionTexture&&r.RefractionTextureEnabled){if(!this._refractionTexture.isReadyOrNotBlocking())return!1;a._needUVs=!0,a.REFRACTION=!0,a.REFRACTIONMAP_3D=this._refractionTexture.isCube}else a.REFRACTION=!1;a.TWOSIDEDLIGHTING=!this._backFaceCulling&&this._twoSidedLighting}else a.DIFFUSE=!1,a.AMBIENT=!1,a.OPACITY=!1,a.REFLECTION=!1,a.EMISSIVE=!1,a.LIGHTMAP=!1,a.BUMP=!1,a.REFRACTION=!1;a.ALPHAFROMDIFFUSE=this._shouldUseAlphaFromDiffuseTexture(),a.EMISSIVEASILLUMINATION=this._useEmissiveAsIllumination,a.LINKEMISSIVEWITHDIFFUSE=this._linkEmissiveWithDiffuse,a.SPECULAROVERALPHA=this._useSpecularOverAlpha,a.PREMULTIPLYALPHA=this.alphaMode===e.Engine.ALPHA_PREMULTIPLIED||this.alphaMode===e.Engine.ALPHA_PREMULTIPLIED_PORTERDUFF}if(a._areImageProcessingDirty){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(a)}if(a._areFresnelDirty&&(r.FresnelEnabled?(this._diffuseFresnelParameters||this._opacityFresnelParameters||this._emissiveFresnelParameters||this._refractionFresnelParameters||this._reflectionFresnelParameters)&&(a.DIFFUSEFRESNEL=this._diffuseFresnelParameters&&this._diffuseFresnelParameters.isEnabled,a.OPACITYFRESNEL=this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled,a.REFLECTIONFRESNEL=this._reflectionFresnelParameters&&this._reflectionFresnelParameters.isEnabled,a.REFLECTIONFRESNELFROMSPECULAR=this._useReflectionFresnelFromSpecular,a.REFRACTIONFRESNEL=this._refractionFresnelParameters&&this._refractionFresnelParameters.isEnabled,a.EMISSIVEFRESNEL=this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled,a._needNormals=!0,a.FRESNEL=!0):a.FRESNEL=!1),e.MaterialHelper.PrepareDefinesForMisc(i,s,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,a),e.MaterialHelper.PrepareDefinesForAttributes(i,a,!0,!0,!0),e.MaterialHelper.PrepareDefinesForFrameBoundValues(s,l,a,o),a.isDirty){a.markAsProcessed(),s.resetCachedMaterial();var h=new e.EffectFallbacks;a.REFLECTION&&h.addFallback(0,"REFLECTION"),a.SPECULAR&&h.addFallback(0,"SPECULAR"),a.BUMP&&h.addFallback(0,"BUMP"),a.PARALLAX&&h.addFallback(1,"PARALLAX"),a.PARALLAXOCCLUSION&&h.addFallback(0,"PARALLAXOCCLUSION"),a.SPECULAROVERALPHA&&h.addFallback(0,"SPECULAROVERALPHA"),a.FOG&&h.addFallback(1,"FOG"),a.POINTSIZE&&h.addFallback(0,"POINTSIZE"),a.LOGARITHMICDEPTH&&h.addFallback(0,"LOGARITHMICDEPTH"),e.MaterialHelper.HandleFallbacksForShadows(a,h,this._maxSimultaneousLights),a.SPECULARTERM&&h.addFallback(0,"SPECULARTERM"),a.DIFFUSEFRESNEL&&h.addFallback(1,"DIFFUSEFRESNEL"),a.OPACITYFRESNEL&&h.addFallback(2,"OPACITYFRESNEL"),a.REFLECTIONFRESNEL&&h.addFallback(3,"REFLECTIONFRESNEL"),a.EMISSIVEFRESNEL&&h.addFallback(4,"EMISSIVEFRESNEL"),a.FRESNEL&&h.addFallback(4,"FRESNEL");var u=[e.VertexBuffer.PositionKind];a.NORMAL&&u.push(e.VertexBuffer.NormalKind),a.UV1&&u.push(e.VertexBuffer.UVKind),a.UV2&&u.push(e.VertexBuffer.UV2Kind),a.VERTEXCOLOR&&u.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(u,i,a,h),e.MaterialHelper.PrepareAttributesForInstances(u,a),e.MaterialHelper.PrepareAttributesForMorphTargets(u,i,a);var c="default",f=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vDiffuseColor","vSpecularColor","vEmissiveColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vSpecularInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","diffuseMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","specularMatrix","bumpMatrix","lightmapMatrix","refractionMatrix","diffuseLeftColor","diffuseRightColor","opacityParts","reflectionLeftColor","reflectionRightColor","emissiveLeftColor","emissiveRightColor","refractionLeftColor","refractionRightColor","logarithmicDepthConstant","vTangentSpaceParams"],d=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler"],p=["Material","Scene"];e.ImageProcessingConfiguration.PrepareUniforms(f,a),e.ImageProcessingConfiguration.PrepareSamplers(d,a),e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:a,maxSimultaneousLights:this._maxSimultaneousLights}),this.customShaderNameResolve&&(c=this.customShaderNameResolve(c,f,p,d,a));var _=a.toString();n.setEffect(s.getEngine().createEffect(c,{attributes:u,uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:_,fallbacks:h,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:a.NUM_MORPH_INFLUENCERS}},l),a),this.buildUniformLayout()}return!(!n.effect||!n.effect.isReady())&&(a._renderId=s.getRenderId(),this._wasPreviouslyReady=!0,!0)},r.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("diffuseLeftColor",4),this._uniformBuffer.addUniform("diffuseRightColor",4),this._uniformBuffer.addUniform("opacityParts",4),this._uniformBuffer.addUniform("reflectionLeftColor",4),this._uniformBuffer.addUniform("reflectionRightColor",4),this._uniformBuffer.addUniform("refractionLeftColor",4),this._uniformBuffer.addUniform("refractionRightColor",4),this._uniformBuffer.addUniform("emissiveLeftColor",4),this._uniformBuffer.addUniform("emissiveRightColor",4),this._uniformBuffer.addUniform("vDiffuseInfos",2),this._uniformBuffer.addUniform("vAmbientInfos",2),this._uniformBuffer.addUniform("vOpacityInfos",2),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("vEmissiveInfos",2),this._uniformBuffer.addUniform("vLightmapInfos",2),this._uniformBuffer.addUniform("vSpecularInfos",2),this._uniformBuffer.addUniform("vBumpInfos",3),this._uniformBuffer.addUniform("diffuseMatrix",16),this._uniformBuffer.addUniform("ambientMatrix",16),this._uniformBuffer.addUniform("opacityMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("emissiveMatrix",16),this._uniformBuffer.addUniform("lightmapMatrix",16),this._uniformBuffer.addUniform("specularMatrix",16),this._uniformBuffer.addUniform("bumpMatrix",16),this._uniformBuffer.addUniform("vTangentSpaceParams",2),this._uniformBuffer.addUniform("refractionMatrix",16),this._uniformBuffer.addUniform("vRefractionInfos",4),this._uniformBuffer.addUniform("vSpecularColor",4),this._uniformBuffer.addUniform("vEmissiveColor",3),this._uniformBuffer.addUniform("vDiffuseColor",4),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.create()},r.prototype.unbind=function(){this._activeEffect&&(this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._activeEffect.setTexture("reflection2DSampler",null),this._refractionTexture&&this._refractionTexture.isRenderTarget&&this._activeEffect.setTexture("refraction2DSampler",null)),i.prototype.unbind.call(this)},r.prototype.bindForSubMesh=function(t,i,n){var o=this.getScene(),s=n._materialDefines;if(s){var a=n.effect;if(a){this._activeEffect=a,this.bindOnlyWorldMatrix(t);var l=this._mustRebind(o,a,i.visibility);if(e.MaterialHelper.BindBonesParameters(i,a),l){if(this._uniformBuffer.bindToEffect(a,"Material"),this.bindViewProjection(a),!this._uniformBuffer.useUbo||!this.isFrozen||!this._uniformBuffer.isSync){if(r.FresnelEnabled&&s.FRESNEL&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),this._uniformBuffer.updateColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&this._uniformBuffer.updateColor4("opacityParts",new e.Color3(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),this._uniformBuffer.updateColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("refractionLeftColor",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),this._uniformBuffer.updateColor4("refractionRightColor",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),this._uniformBuffer.updateColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))), o.texturesEnabled&&(this._diffuseTexture&&r.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),e.MaterialHelper.BindTextureMatrix(this._diffuseTexture,this._uniformBuffer,"diffuse")),this._ambientTexture&&r.AmbientTextureEnabled&&(this._uniformBuffer.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),e.MaterialHelper.BindTextureMatrix(this._ambientTexture,this._uniformBuffer,"ambient")),this._opacityTexture&&r.OpacityTextureEnabled&&(this._uniformBuffer.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),e.MaterialHelper.BindTextureMatrix(this._opacityTexture,this._uniformBuffer,"opacity")),this._reflectionTexture&&r.ReflectionTextureEnabled&&(this._uniformBuffer.updateFloat2("vReflectionInfos",this._reflectionTexture.level,this.roughness),this._uniformBuffer.updateMatrix("reflectionMatrix",this._reflectionTexture.getReflectionTextureMatrix())),this._emissiveTexture&&r.EmissiveTextureEnabled&&(this._uniformBuffer.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),e.MaterialHelper.BindTextureMatrix(this._emissiveTexture,this._uniformBuffer,"emissive")),this._lightmapTexture&&r.LightmapTextureEnabled&&(this._uniformBuffer.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),e.MaterialHelper.BindTextureMatrix(this._lightmapTexture,this._uniformBuffer,"lightmap")),this._specularTexture&&r.SpecularTextureEnabled&&(this._uniformBuffer.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),e.MaterialHelper.BindTextureMatrix(this._specularTexture,this._uniformBuffer,"specular")),this._bumpTexture&&o.getEngine().getCaps().standardDerivatives&&r.BumpTextureEnabled&&(this._uniformBuffer.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),e.MaterialHelper.BindTextureMatrix(this._bumpTexture,this._uniformBuffer,"bump"),o._mirroredCameraPosition?this._uniformBuffer.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):this._uniformBuffer.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),this._refractionTexture&&r.RefractionTextureEnabled)){var h=1;this._refractionTexture.isCube||(this._uniformBuffer.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(h=this._refractionTexture.depth)),this._uniformBuffer.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,h,this.invertRefractionY?-1:1)}this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),s.SPECULARTERM&&this._uniformBuffer.updateColor4("vSpecularColor",this.specularColor,this.specularPower),this._uniformBuffer.updateColor3("vEmissiveColor",this.emissiveColor),this._uniformBuffer.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility)}if(o.texturesEnabled&&(this._diffuseTexture&&r.DiffuseTextureEnabled&&a.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&r.AmbientTextureEnabled&&a.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&r.OpacityTextureEnabled&&a.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&r.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?a.setTexture("reflectionCubeSampler",this._reflectionTexture):a.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&r.EmissiveTextureEnabled&&a.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&r.LightmapTextureEnabled&&a.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&r.SpecularTextureEnabled&&a.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&o.getEngine().getCaps().standardDerivatives&&r.BumpTextureEnabled&&a.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&r.RefractionTextureEnabled)){var h=1;this._refractionTexture.isCube?a.setTexture("refractionCubeSampler",this._refractionTexture):a.setTexture("refraction2DSampler",this._refractionTexture)}e.MaterialHelper.BindClipPlane(a,o),o.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),e.MaterialHelper.BindEyePosition(a,o),a.setColor3("vAmbientColor",this._globalAmbientColor)}!l&&this.isFrozen||(o.lightsEnabled&&!this._disableLighting&&e.MaterialHelper.BindLights(o,i,a,s,this._maxSimultaneousLights),(o.fogEnabled&&i.applyFog&&o.fogMode!==e.Scene.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture)&&this.bindView(a),e.MaterialHelper.BindFogParameters(o,i,a),s.NUM_MORPH_INFLUENCERS&&e.MaterialHelper.BindMorphTargetParameters(i,a),e.MaterialHelper.BindLogDepth(s,a,o),this._imageProcessingConfiguration.bind(this._activeEffect)),this._uniformBuffer.update(),this._afterBind(i,this._activeEffect)}}},r.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._specularTexture&&this._specularTexture.animations&&this._specularTexture.animations.length>0&&e.push(this._specularTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),e},r.prototype.getActiveTextures=function(){var e=i.prototype.getActiveTextures.call(this);return this._diffuseTexture&&e.push(this._diffuseTexture),this._ambientTexture&&e.push(this._ambientTexture),this._opacityTexture&&e.push(this._opacityTexture),this._reflectionTexture&&e.push(this._reflectionTexture),this._emissiveTexture&&e.push(this._emissiveTexture),this._specularTexture&&e.push(this._specularTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),this._refractionTexture&&e.push(this._refractionTexture),e},r.prototype.hasTexture=function(e){return!!i.prototype.hasTexture.call(this,e)||(this._diffuseTexture===e||(this._ambientTexture===e||(this._opacityTexture===e||(this._reflectionTexture===e||(this._emissiveTexture===e||(this._specularTexture===e||(this._bumpTexture===e||(this._lightmapTexture===e||this._refractionTexture===e))))))))},r.prototype.dispose=function(e,t){t&&(this._diffuseTexture&&this._diffuseTexture.dispose(),this._ambientTexture&&this._ambientTexture.dispose(),this._opacityTexture&&this._opacityTexture.dispose(),this._reflectionTexture&&this._reflectionTexture.dispose(),this._emissiveTexture&&this._emissiveTexture.dispose(),this._specularTexture&&this._specularTexture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._lightmapTexture&&this._lightmapTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose()),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),i.prototype.dispose.call(this,e,t)},r.prototype.clone=function(t){var i=this,n=e.SerializationHelper.Clone((function(){return new r(t,i.getScene())}),this);return n.name=t,n.id=t,n},r.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},r.Parse=function(t,i,n){return e.SerializationHelper.Parse((function(){return new r(t.name,i)}),t,i,n)},Object.defineProperty(r,"DiffuseTextureEnabled",{get:function(){return r._DiffuseTextureEnabled},set:function(t){r._DiffuseTextureEnabled!==t&&(r._DiffuseTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"AmbientTextureEnabled",{get:function(){return r._AmbientTextureEnabled},set:function(t){r._AmbientTextureEnabled!==t&&(r._AmbientTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"OpacityTextureEnabled",{get:function(){return r._OpacityTextureEnabled},set:function(t){r._OpacityTextureEnabled!==t&&(r._OpacityTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"ReflectionTextureEnabled",{get:function(){return r._ReflectionTextureEnabled},set:function(t){r._ReflectionTextureEnabled!==t&&(r._ReflectionTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"EmissiveTextureEnabled",{get:function(){return r._EmissiveTextureEnabled},set:function(t){r._EmissiveTextureEnabled!==t&&(r._EmissiveTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"SpecularTextureEnabled",{get:function(){return r._SpecularTextureEnabled},set:function(t){r._SpecularTextureEnabled!==t&&(r._SpecularTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"BumpTextureEnabled",{get:function(){return r._BumpTextureEnabled},set:function(t){r._BumpTextureEnabled!==t&&(r._BumpTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"LightmapTextureEnabled",{get:function(){return r._LightmapTextureEnabled},set:function(t){r._LightmapTextureEnabled!==t&&(r._LightmapTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"RefractionTextureEnabled",{get:function(){return r._RefractionTextureEnabled},set:function(t){r._RefractionTextureEnabled!==t&&(r._RefractionTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"ColorGradingTextureEnabled",{get:function(){return r._ColorGradingTextureEnabled},set:function(t){r._ColorGradingTextureEnabled!==t&&(r._ColorGradingTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"FresnelEnabled",{get:function(){return r._FresnelEnabled},set:function(t){r._FresnelEnabled!==t&&(r._FresnelEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.FresnelDirtyFlag))},enumerable:!0,configurable:!0}),r._DiffuseTextureEnabled=!0,r._AmbientTextureEnabled=!0,r._OpacityTextureEnabled=!0,r._ReflectionTextureEnabled=!0,r._EmissiveTextureEnabled=!0,r._SpecularTextureEnabled=!0,r._BumpTextureEnabled=!0,r._LightmapTextureEnabled=!0,r._RefractionTextureEnabled=!0,r._ColorGradingTextureEnabled=!0,r._FresnelEnabled=!0,__decorate([e.serializeAsTexture("diffuseTexture")],r.prototype,"_diffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsTexture("ambientTexture")],r.prototype,"_ambientTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"ambientTexture",void 0),__decorate([e.serializeAsTexture("opacityTexture")],r.prototype,"_opacityTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture("reflectionTexture")],r.prototype,"_reflectionTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture("emissiveTexture")],r.prototype,"_emissiveTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture("specularTexture")],r.prototype,"_specularTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"specularTexture",void 0),__decorate([e.serializeAsTexture("bumpTexture")],r.prototype,"_bumpTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture("lightmapTexture")],r.prototype,"_lightmapTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture("refractionTexture")],r.prototype,"_refractionTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient")],r.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("diffuse")],r.prototype,"diffuseColor",void 0),__decorate([e.serializeAsColor3("specular")],r.prototype,"specularColor",void 0),__decorate([e.serializeAsColor3("emissive")],r.prototype,"emissiveColor",void 0),__decorate([e.serialize()],r.prototype,"specularPower",void 0),__decorate([e.serialize("useAlphaFromDiffuseTexture")],r.prototype,"_useAlphaFromDiffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useAlphaFromDiffuseTexture",void 0),__decorate([e.serialize("useEmissiveAsIllumination")],r.prototype,"_useEmissiveAsIllumination",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useEmissiveAsIllumination",void 0),__decorate([e.serialize("linkEmissiveWithDiffuse")],r.prototype,"_linkEmissiveWithDiffuse",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"linkEmissiveWithDiffuse",void 0),__decorate([e.serialize("useSpecularOverAlpha")],r.prototype,"_useSpecularOverAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize("useReflectionOverAlpha")],r.prototype,"_useReflectionOverAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useReflectionOverAlpha",void 0),__decorate([e.serialize("disableLighting")],r.prototype,"_disableLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],r.prototype,"disableLighting",void 0),__decorate([e.serialize("useParallax")],r.prototype,"_useParallax",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useParallax",void 0),__decorate([e.serialize("useParallaxOcclusion")],r.prototype,"_useParallaxOcclusion",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize()],r.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize("roughness")],r.prototype,"_roughness",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"roughness",void 0),__decorate([e.serialize()],r.prototype,"indexOfRefraction",void 0),__decorate([e.serialize()],r.prototype,"invertRefractionY",void 0),__decorate([e.serialize("useLightmapAsShadowmap")],r.prototype,"_useLightmapAsShadowmap",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serializeAsFresnelParameters("diffuseFresnelParameters")],r.prototype,"_diffuseFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"diffuseFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("opacityFresnelParameters")],r.prototype,"_opacityFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"opacityFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("reflectionFresnelParameters")],r.prototype,"_reflectionFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"reflectionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("refractionFresnelParameters")],r.prototype,"_refractionFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"refractionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("emissiveFresnelParameters")],r.prototype,"_emissiveFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"emissiveFresnelParameters",void 0),__decorate([e.serialize("useReflectionFresnelFromSpecular")],r.prototype,"_useReflectionFresnelFromSpecular",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"useReflectionFresnelFromSpecular",void 0),__decorate([e.serialize("useGlossinessFromSpecularMapAlpha")],r.prototype,"_useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.serialize("maxSimultaneousLights")],r.prototype,"_maxSimultaneousLights",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],r.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize("invertNormalMapX")],r.prototype,"_invertNormalMapX",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"invertNormalMapX",void 0),__decorate([e.serialize("invertNormalMapY")],r.prototype,"_invertNormalMapY",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"invertNormalMapY",void 0),__decorate([e.serialize("twoSidedLighting")],r.prototype,"_twoSidedLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"twoSidedLighting",void 0),__decorate([e.serialize()],r.prototype,"useLogarithmicDepth",null),r})(e.PushMaterial);e.StandardMaterial=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(){var t=e.call(this)||this;return t.PBR=!0,t.MAINUV1=!1,t.MAINUV2=!1,t.UV1=!1,t.UV2=!1,t.ALBEDO=!1,t.ALBEDODIRECTUV=0,t.VERTEXCOLOR=!1,t.AMBIENT=!1,t.AMBIENTDIRECTUV=0,t.AMBIENTINGRAYSCALE=!1,t.OPACITY=!1,t.VERTEXALPHA=!1,t.OPACITYDIRECTUV=0,t.OPACITYRGB=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!1,t.ALPHABLEND=!1,t.ALPHAFROMALBEDO=!1,t.ALPHATESTVALUE=.5,t.SPECULAROVERALPHA=!1,t.RADIANCEOVERALPHA=!1,t.ALPHAFRESNEL=!1,t.PREMULTIPLYALPHA=!1,t.EMISSIVE=!1,t.EMISSIVEDIRECTUV=0,t.REFLECTIVITY=!1,t.REFLECTIVITYDIRECTUV=0,t.SPECULARTERM=!1,t.MICROSURFACEFROMREFLECTIVITYMAP=!1,t.MICROSURFACEAUTOMATIC=!1,t.LODBASEDMICROSFURACE=!1,t.MICROSURFACEMAP=!1,t.MICROSURFACEMAPDIRECTUV=0,t.METALLICWORKFLOW=!1,t.ROUGHNESSSTOREINMETALMAPALPHA=!1,t.ROUGHNESSSTOREINMETALMAPGREEN=!1,t.METALLNESSSTOREINMETALMAPBLUE=!1,t.AOSTOREINMETALMAPRED=!1,t.ENVIRONMENTBRDF=!1,t.NORMAL=!1,t.TANGENT=!1,t.BUMP=!1,t.BUMPDIRECTUV=0,t.PARALLAX=!1,t.PARALLAXOCCLUSION=!1,t.NORMALXYSCALE=!0,t.LIGHTMAP=!1,t.LIGHTMAPDIRECTUV=0,t.USELIGHTMAPASSHADOWMAP=!1,t.REFLECTION=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.USESPHERICALFROMREFLECTIONMAP=!1,t.USESPHERICALINVERTEX=!1,t.REFLECTIONMAP_OPPOSITEZ=!1,t.LODINREFLECTIONALPHA=!1,t.GAMMAREFLECTION=!1,t.REFRACTION=!1,t.REFRACTIONMAP_3D=!1,t.REFRACTIONMAP_OPPOSITEZ=!1,t.LODINREFRACTIONALPHA=!1,t.GAMMAREFRACTION=!1,t.LINKREFRACTIONTOTRANSPARENCY=!1,t.INSTANCES=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.NONUNIFORMSCALING=!1,t.MORPHTARGETS=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS_TANGENT=!1,t.NUM_MORPH_INFLUENCERS=0,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.COLORGRADING3D=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.EXPOSURE=!1,t.USEPHYSICALLIGHTFALLOFF=!1,t.TWOSIDEDLIGHTING=!1,t.SHADOWFLOAT=!1,t.CLIPPLANE=!1,t.POINTSIZE=!1,t.FOG=!1,t.LOGARITHMICDEPTH=!1,t.FORCENORMALFORWARD=!1,t.rebuild(),t}return __extends(t,e),t.prototype.reset=function(){e.prototype.reset.call(this),this.ALPHATESTVALUE=.5,this.PBR=!0},t})(e.MaterialDefines),i=(function(i){function r(t,r){var n=i.call(this,t,r)||this;return n._directIntensity=1,n._emissiveIntensity=1,n._environmentIntensity=1,n._specularIntensity=1,n._lightingInfos=new e.Vector4(n._directIntensity,n._emissiveIntensity,n._environmentIntensity,n._specularIntensity),n._disableBumpMap=!1,n._ambientTextureStrength=1,n._ambientColor=new e.Color3(0,0,0),n._albedoColor=new e.Color3(1,1,1),n._reflectivityColor=new e.Color3(1,1,1),n._reflectionColor=new e.Color3(1,1,1),n._emissiveColor=new e.Color3(0,0,0),n._microSurface=.9,n._indexOfRefraction=.66,n._invertRefractionY=!1,n._linkRefractionWithTransparency=!1,n._useLightmapAsShadowmap=!1,n._useAlphaFromAlbedoTexture=!1,n._useSpecularOverAlpha=!0,n._useMicroSurfaceFromReflectivityMapAlpha=!1,n._useRoughnessFromMetallicTextureAlpha=!0,n._useRoughnessFromMetallicTextureGreen=!1,n._useMetallnessFromMetallicTextureBlue=!1,n._useAmbientOcclusionFromMetallicTextureRed=!1,n._useAmbientInGrayScale=!1,n._useAutoMicroSurfaceFromReflectivityMap=!1,n._usePhysicalLightFalloff=!0,n._useRadianceOverAlpha=!0,n._useParallax=!1,n._useParallaxOcclusion=!1,n._parallaxScaleBias=.05,n._disableLighting=!1,n._maxSimultaneousLights=4,n._invertNormalMapX=!1,n._invertNormalMapY=!1,n._twoSidedLighting=!1,n._alphaCutOff=.4,n._forceAlphaTest=!1,n._useAlphaFresnel=!1,n._transparencyMode=null,n._environmentBRDFTexture=null,n._forceIrradianceInFragment=!1,n._forceNormalForward=!1,n._renderTargets=new e.SmartArray(16),n._globalAmbientColor=new e.Color3(0,0,0),n._attachImageProcessingConfiguration(null),n.getRenderTargetTextures=function(){return n._renderTargets.reset(),e.StandardMaterial.ReflectionTextureEnabled&&n._reflectionTexture&&n._reflectionTexture.isRenderTarget&&n._renderTargets.push(n._reflectionTexture),e.StandardMaterial.RefractionTextureEnabled&&n._refractionTexture&&n._refractionTexture.isRenderTarget&&n._renderTargets.push(n._refractionTexture),n._renderTargets},n._environmentBRDFTexture=e.TextureTools.GetEnvironmentBRDFTexture(r),n}return __extends(r,i),r.prototype._attachImageProcessingConfiguration=function(e){var t=this;e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration=e||this.getScene().imageProcessingConfiguration,this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(e){t._markAllSubMeshesAsImageProcessingDirty()})))},r.prototype.getClassName=function(){return"PBRBaseMaterial"},Object.defineProperty(r.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"transparencyMode",{get:function(){return this._transparencyMode},set:function(t){this._transparencyMode!==t&&(this._transparencyMode=t,this._forceAlphaTest=t===e.PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND,this._markAllSubMeshesAsTexturesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"_disableAlphaBlending",{get:function(){return this._linkRefractionWithTransparency||this._transparencyMode===e.PBRMaterial.PBRMATERIAL_OPAQUE||this._transparencyMode===e.PBRMaterial.PBRMATERIAL_ALPHATEST},enumerable:!0,configurable:!0}),r.prototype.needAlphaBlending=function(){return!this._disableAlphaBlending&&(this.alpha<1||null!=this._opacityTexture||this._shouldUseAlphaFromAlbedoTexture())},r.prototype.needAlphaBlendingForMesh=function(e){return!this._disableAlphaBlending&&i.prototype.needAlphaBlendingForMesh.call(this,e)},r.prototype.needAlphaTesting=function(){return!!this._forceAlphaTest||!this._linkRefractionWithTransparency&&(null!=this._albedoTexture&&this._albedoTexture.hasAlpha&&this._transparencyMode===e.PBRMaterial.PBRMATERIAL_ALPHATEST)},r.prototype._shouldUseAlphaFromAlbedoTexture=function(){return null!=this._albedoTexture&&this._albedoTexture.hasAlpha&&this._useAlphaFromAlbedoTexture&&this._transparencyMode!==e.PBRMaterial.PBRMATERIAL_OPAQUE},r.prototype.getAlphaTestTexture=function(){return this._albedoTexture},r.prototype.isReadyForSubMesh=function(i,r,n){var o=this;if(r.effect&&this.isFrozen&&this._wasPreviouslyReady)return!0;r._materialDefines||(r._materialDefines=new t);var s=this.getScene(),a=r._materialDefines;if(!this.checkReadyOnEveryCall&&r.effect&&a._renderId===s.getRenderId())return!0;var l=s.getEngine();if(e.MaterialHelper.PrepareDefinesForLights(s,i,a,!0,this._maxSimultaneousLights,this._disableLighting),a._needNormals=!0,a._areTexturesDirty){if(a._needUVs=!1,s.texturesEnabled){if(s.getEngine().getCaps().textureLOD&&(a.LODBASEDMICROSFURACE=!0),this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled){if(!this._albedoTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._albedoTexture,a,"ALBEDO")}else a.ALBEDO=!1;if(this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled){if(!this._ambientTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._ambientTexture,a,"AMBIENT"),a.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale}else a.AMBIENT=!1;if(this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled){if(!this._opacityTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._opacityTexture,a,"OPACITY"),a.OPACITYRGB=this._opacityTexture.getAlphaFromRGB}else a.OPACITY=!1;var h=this._getReflectionTexture();if(h&&e.StandardMaterial.ReflectionTextureEnabled){if(!h.isReadyOrNotBlocking())return!1;switch(a.REFLECTION=!0,a.GAMMAREFLECTION=h.gammaSpace,a.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!h.invertZ:h.invertZ,a.LODINREFLECTIONALPHA=h.lodLevelInAlpha,h.coordinatesMode===e.Texture.INVCUBIC_MODE&&(a.INVERTCUBICMAP=!0),a.REFLECTIONMAP_3D=h.isCube,h.coordinatesMode){case e.Texture.CUBIC_MODE:case e.Texture.INVCUBIC_MODE:a.REFLECTIONMAP_CUBIC=!0;break;case e.Texture.EXPLICIT_MODE:a.REFLECTIONMAP_EXPLICIT=!0;break;case e.Texture.PLANAR_MODE:a.REFLECTIONMAP_PLANAR=!0;break;case e.Texture.PROJECTION_MODE:a.REFLECTIONMAP_PROJECTION=!0;break;case e.Texture.SKYBOX_MODE:a.REFLECTIONMAP_SKYBOX=!0;break;case e.Texture.SPHERICAL_MODE:a.REFLECTIONMAP_SPHERICAL=!0;break;case e.Texture.EQUIRECTANGULAR_MODE:a.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case e.Texture.FIXED_EQUIRECTANGULAR_MODE:a.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case e.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:a.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0}h.coordinatesMode!==e.Texture.SKYBOX_MODE&&h.sphericalPolynomial&&(a.USESPHERICALFROMREFLECTIONMAP=!0,this._forceIrradianceInFragment||s.getEngine().getCaps().maxVaryingVectors<=8?a.USESPHERICALINVERTEX=!1:a.USESPHERICALINVERTEX=!0)}else a.REFLECTION=!1,a.REFLECTIONMAP_3D=!1,a.REFLECTIONMAP_SPHERICAL=!1,a.REFLECTIONMAP_PLANAR=!1,a.REFLECTIONMAP_CUBIC=!1,a.REFLECTIONMAP_PROJECTION=!1,a.REFLECTIONMAP_SKYBOX=!1,a.REFLECTIONMAP_EXPLICIT=!1,a.REFLECTIONMAP_EQUIRECTANGULAR=!1,a.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,a.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,a.INVERTCUBICMAP=!1,a.USESPHERICALFROMREFLECTIONMAP=!1,a.USESPHERICALINVERTEX=!1,a.REFLECTIONMAP_OPPOSITEZ=!1,a.LODINREFLECTIONALPHA=!1,a.GAMMAREFLECTION=!1;if(this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._lightmapTexture,a,"LIGHTMAP"),a.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap}else a.LIGHTMAP=!1;if(this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._emissiveTexture,a,"EMISSIVE")}else a.EMISSIVE=!1;if(e.StandardMaterial.SpecularTextureEnabled){if(this._metallicTexture){if(!this._metallicTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._metallicTexture,a,"REFLECTIVITY"),a.METALLICWORKFLOW=!0,a.ROUGHNESSSTOREINMETALMAPALPHA=this._useRoughnessFromMetallicTextureAlpha,a.ROUGHNESSSTOREINMETALMAPGREEN=!this._useRoughnessFromMetallicTextureAlpha&&this._useRoughnessFromMetallicTextureGreen,a.METALLNESSSTOREINMETALMAPBLUE=this._useMetallnessFromMetallicTextureBlue,a.AOSTOREINMETALMAPRED=this._useAmbientOcclusionFromMetallicTextureRed}else if(this._reflectivityTexture){if(!this._reflectivityTexture.isReadyOrNotBlocking())return!1;a.METALLICWORKFLOW=!1,e.MaterialHelper.PrepareDefinesForMergedUV(this._reflectivityTexture,a,"REFLECTIVITY"),a.MICROSURFACEFROMREFLECTIVITYMAP=this._useMicroSurfaceFromReflectivityMapAlpha,a.MICROSURFACEAUTOMATIC=this._useAutoMicroSurfaceFromReflectivityMap}else a.METALLICWORKFLOW=!1,a.REFLECTIVITY=!1;if(this._microSurfaceTexture){if(!this._microSurfaceTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._microSurfaceTexture,a,"MICROSURFACEMAP")}else a.MICROSURFACEMAP=!1}else a.REFLECTIVITY=!1,a.MICROSURFACEMAP=!1;if(s.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap){if(!this._bumpTexture.isReady())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._bumpTexture,a,"BUMP"),this._useParallax&&this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled?(a.PARALLAX=!0,a.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):a.PARALLAX=!1}else a.BUMP=!1;var u=this._getRefractionTexture();if(u&&e.StandardMaterial.RefractionTextureEnabled){if(!u.isReadyOrNotBlocking())return!1;a.REFRACTION=!0,a.REFRACTIONMAP_3D=u.isCube,a.GAMMAREFRACTION=u.gammaSpace,a.REFRACTIONMAP_OPPOSITEZ=h.invertZ,a.LODINREFRACTIONALPHA=h.lodLevelInAlpha,this._linkRefractionWithTransparency&&(a.LINKREFRACTIONTOTRANSPARENCY=!0)}else a.REFRACTION=!1;if(this._environmentBRDFTexture&&e.StandardMaterial.ReflectionTextureEnabled){if(!this._environmentBRDFTexture.isReady())return!1;a.ENVIRONMENTBRDF=!0}else a.ENVIRONMENTBRDF=!1;this._shouldUseAlphaFromAlbedoTexture()?a.ALPHAFROMALBEDO=!0:a.ALPHAFROMALBEDO=!1}a.SPECULAROVERALPHA=this._useSpecularOverAlpha,a.USEPHYSICALLIGHTFALLOFF=this._usePhysicalLightFalloff,a.RADIANCEOVERALPHA=this._useRadianceOverAlpha,void 0!==this._metallic&&null!==this._metallic||void 0!==this._roughness&&null!==this._roughness?a.METALLICWORKFLOW=!0:a.METALLICWORKFLOW=!1,!this.backFaceCulling&&this._twoSidedLighting?a.TWOSIDEDLIGHTING=!0:a.TWOSIDEDLIGHTING=!1,a.ALPHATESTVALUE=this._alphaCutOff,a.PREMULTIPLYALPHA=this.alphaMode===e.Engine.ALPHA_PREMULTIPLIED||this.alphaMode===e.Engine.ALPHA_PREMULTIPLIED_PORTERDUFF,a.ALPHABLEND=this.needAlphaBlendingForMesh(i),a.ALPHAFRESNEL=this._useAlphaFresnel}if(a._areImageProcessingDirty){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(a)}if(a.FORCENORMALFORWARD=this._forceNormalForward,e.MaterialHelper.PrepareDefinesForMisc(i,s,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,a),e.MaterialHelper.PrepareDefinesForFrameBoundValues(s,l,a,!!n,this._forceAlphaTest), e.MaterialHelper.PrepareDefinesForAttributes(i,a,!0,!0,!0,this._transparencyMode!==e.PBRMaterial.PBRMATERIAL_OPAQUE)&&i&&(s.getEngine().getCaps().standardDerivatives||i.isVerticesDataPresent(e.VertexBuffer.NormalKind)||(i.createNormals(!0),e.Tools.Warn("PBRMaterial: Normals have been created for the mesh: "+i.name))),a.isDirty){a.markAsProcessed(),s.resetCachedMaterial();var c=new e.EffectFallbacks,f=0;a.USESPHERICALINVERTEX&&c.addFallback(f++,"USESPHERICALINVERTEX"),a.FOG&&c.addFallback(f,"FOG"),a.POINTSIZE&&c.addFallback(f,"POINTSIZE"),a.LOGARITHMICDEPTH&&c.addFallback(f,"LOGARITHMICDEPTH"),a.PARALLAX&&c.addFallback(f,"PARALLAX"),a.PARALLAXOCCLUSION&&c.addFallback(f++,"PARALLAXOCCLUSION"),a.ENVIRONMENTBRDF&&c.addFallback(f++,"ENVIRONMENTBRDF"),a.TANGENT&&c.addFallback(f++,"TANGENT"),a.BUMP&&c.addFallback(f++,"BUMP"),f=e.MaterialHelper.HandleFallbacksForShadows(a,c,this._maxSimultaneousLights,f++),a.SPECULARTERM&&c.addFallback(f++,"SPECULARTERM"),a.USESPHERICALFROMREFLECTIONMAP&&c.addFallback(f++,"USESPHERICALFROMREFLECTIONMAP"),a.LIGHTMAP&&c.addFallback(f++,"LIGHTMAP"),a.NORMAL&&c.addFallback(f++,"NORMAL"),a.AMBIENT&&c.addFallback(f++,"AMBIENT"),a.EMISSIVE&&c.addFallback(f++,"EMISSIVE"),a.VERTEXCOLOR&&c.addFallback(f++,"VERTEXCOLOR"),a.NUM_BONE_INFLUENCERS>0&&c.addCPUSkinningFallback(f++,i),a.MORPHTARGETS&&c.addFallback(f++,"MORPHTARGETS");var d=[e.VertexBuffer.PositionKind];a.NORMAL&&d.push(e.VertexBuffer.NormalKind),a.TANGENT&&d.push(e.VertexBuffer.TangentKind),a.UV1&&d.push(e.VertexBuffer.UVKind),a.UV2&&d.push(e.VertexBuffer.UV2Kind),a.VERTEXCOLOR&&d.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(d,i,a,c),e.MaterialHelper.PrepareAttributesForInstances(d,a),e.MaterialHelper.PrepareAttributesForMorphTargets(d,i,a);var p=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vAlbedoColor","vReflectivityColor","vEmissiveColor","vReflectionColor","vFogInfos","vFogColor","pointSize","vAlbedoInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vReflectivityInfos","vMicroSurfaceSamplerInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","albedoMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","reflectivityMatrix","microSurfaceSamplerMatrix","bumpMatrix","lightmapMatrix","refractionMatrix","vLightingIntensity","logarithmicDepthConstant","vSphericalX","vSphericalY","vSphericalZ","vSphericalXX","vSphericalYY","vSphericalZZ","vSphericalXY","vSphericalYZ","vSphericalZX","vReflectionMicrosurfaceInfos","vRefractionMicrosurfaceInfos","vTangentSpaceParams"],_=["albedoSampler","reflectivitySampler","ambientSampler","emissiveSampler","bumpSampler","lightmapSampler","opacitySampler","refractionSampler","refractionSamplerLow","refractionSamplerHigh","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh","microSurfaceSampler","environmentBrdfSampler"],m=["Material","Scene"];e.ImageProcessingConfiguration.PrepareUniforms(p,a),e.ImageProcessingConfiguration.PrepareSamplers(_,a),e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:p,uniformBuffersNames:m,samplers:_,defines:a,maxSimultaneousLights:this._maxSimultaneousLights});var g=function(e){o.onCompiled&&o.onCompiled(e),o.bindSceneUniformBuffer(e,s.getSceneUniformBuffer())},v=a.toString();r.setEffect(s.getEngine().createEffect("pbr",{attributes:d,uniformsNames:p,uniformBuffersNames:m,samplers:_,defines:v,fallbacks:c,onCompiled:g,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:a.NUM_MORPH_INFLUENCERS}},l),a),this.buildUniformLayout()}return!(!r.effect||!r.effect.isReady())&&(a._renderId=s.getRenderId(),this._wasPreviouslyReady=!0,!0)},r.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("vAlbedoInfos",2),this._uniformBuffer.addUniform("vAmbientInfos",3),this._uniformBuffer.addUniform("vOpacityInfos",2),this._uniformBuffer.addUniform("vEmissiveInfos",2),this._uniformBuffer.addUniform("vLightmapInfos",2),this._uniformBuffer.addUniform("vReflectivityInfos",3),this._uniformBuffer.addUniform("vMicroSurfaceSamplerInfos",2),this._uniformBuffer.addUniform("vRefractionInfos",4),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("vBumpInfos",3),this._uniformBuffer.addUniform("albedoMatrix",16),this._uniformBuffer.addUniform("ambientMatrix",16),this._uniformBuffer.addUniform("opacityMatrix",16),this._uniformBuffer.addUniform("emissiveMatrix",16),this._uniformBuffer.addUniform("lightmapMatrix",16),this._uniformBuffer.addUniform("reflectivityMatrix",16),this._uniformBuffer.addUniform("microSurfaceSamplerMatrix",16),this._uniformBuffer.addUniform("bumpMatrix",16),this._uniformBuffer.addUniform("vTangentSpaceParams",2),this._uniformBuffer.addUniform("refractionMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("vReflectionColor",3),this._uniformBuffer.addUniform("vAlbedoColor",4),this._uniformBuffer.addUniform("vLightingIntensity",4),this._uniformBuffer.addUniform("vRefractionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("vReflectivityColor",4),this._uniformBuffer.addUniform("vEmissiveColor",3),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.create()},r.prototype.unbind=function(){this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._uniformBuffer.setTexture("reflectionSampler",null),this._refractionTexture&&this._refractionTexture.isRenderTarget&&this._uniformBuffer.setTexture("refractionSampler",null),i.prototype.unbind.call(this)},r.prototype.bindOnlyWorldMatrix=function(e){this._activeEffect.setMatrix("world",e)},r.prototype.bindForSubMesh=function(t,i,r){var n=this.getScene(),o=r._materialDefines;if(o){var s=r.effect;if(s){this._activeEffect=s,this.bindOnlyWorldMatrix(t);var a=this._mustRebind(n,s,i.visibility);e.MaterialHelper.BindBonesParameters(i,this._activeEffect);var l=null;if(a){this._uniformBuffer.bindToEffect(s,"Material"),this.bindViewProjection(s),l=this._getReflectionTexture();var h=this._getRefractionTexture();if(!this._uniformBuffer.useUbo||!this.isFrozen||!this._uniformBuffer.isSync){if(n.texturesEnabled){if(this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),e.MaterialHelper.BindTextureMatrix(this._albedoTexture,this._uniformBuffer,"albedo")),this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled&&(this._uniformBuffer.updateFloat3("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength),e.MaterialHelper.BindTextureMatrix(this._ambientTexture,this._uniformBuffer,"ambient")),this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled&&(this._uniformBuffer.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),e.MaterialHelper.BindTextureMatrix(this._opacityTexture,this._uniformBuffer,"opacity")),l&&e.StandardMaterial.ReflectionTextureEnabled){this._uniformBuffer.updateMatrix("reflectionMatrix",l.getReflectionTextureMatrix()),this._uniformBuffer.updateFloat2("vReflectionInfos",l.level,0);var u=l.sphericalPolynomial;o.USESPHERICALFROMREFLECTIONMAP&&u&&(this._activeEffect.setFloat3("vSphericalX",u.x.x,u.x.y,u.x.z),this._activeEffect.setFloat3("vSphericalY",u.y.x,u.y.y,u.y.z),this._activeEffect.setFloat3("vSphericalZ",u.z.x,u.z.y,u.z.z),this._activeEffect.setFloat3("vSphericalXX_ZZ",u.xx.x-u.zz.x,u.xx.y-u.zz.y,u.xx.z-u.zz.z),this._activeEffect.setFloat3("vSphericalYY_ZZ",u.yy.x-u.zz.x,u.yy.y-u.zz.y,u.yy.z-u.zz.z),this._activeEffect.setFloat3("vSphericalZZ",u.zz.x,u.zz.y,u.zz.z),this._activeEffect.setFloat3("vSphericalXY",u.xy.x,u.xy.y,u.xy.z),this._activeEffect.setFloat3("vSphericalYZ",u.yz.x,u.yz.y,u.yz.z),this._activeEffect.setFloat3("vSphericalZX",u.zx.x,u.zx.y,u.zx.z)),this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos",l.getSize().width,l.lodGenerationScale,l.lodGenerationOffset)}if(this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled&&(this._uniformBuffer.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),e.MaterialHelper.BindTextureMatrix(this._emissiveTexture,this._uniformBuffer,"emissive")),this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled&&(this._uniformBuffer.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),e.MaterialHelper.BindTextureMatrix(this._lightmapTexture,this._uniformBuffer,"lightmap")),e.StandardMaterial.SpecularTextureEnabled&&(this._metallicTexture?(this._uniformBuffer.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),e.MaterialHelper.BindTextureMatrix(this._metallicTexture,this._uniformBuffer,"reflectivity")):this._reflectivityTexture&&(this._uniformBuffer.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),e.MaterialHelper.BindTextureMatrix(this._reflectivityTexture,this._uniformBuffer,"reflectivity")),this._microSurfaceTexture&&(this._uniformBuffer.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),e.MaterialHelper.BindTextureMatrix(this._microSurfaceTexture,this._uniformBuffer,"microSurfaceSampler"))),this._bumpTexture&&n.getEngine().getCaps().standardDerivatives&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap&&(this._uniformBuffer.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),e.MaterialHelper.BindTextureMatrix(this._bumpTexture,this._uniformBuffer,"bump"),n._mirroredCameraPosition?this._uniformBuffer.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):this._uniformBuffer.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),h&&e.StandardMaterial.RefractionTextureEnabled){this._uniformBuffer.updateMatrix("refractionMatrix",h.getReflectionTextureMatrix());var c=1;h.isCube||h.depth&&(c=h.depth),this._uniformBuffer.updateFloat4("vRefractionInfos",h.level,this._indexOfRefraction,c,this._invertRefractionY?-1:1),this._uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos",h.getSize().width,h.lodGenerationScale,h.lodGenerationOffset)}}this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),o.METALLICWORKFLOW?(e.PBRMaterial._scaledReflectivity.r=void 0===this._metallic||null===this._metallic?1:this._metallic,e.PBRMaterial._scaledReflectivity.g=void 0===this._roughness||null===this._roughness?1:this._roughness,this._uniformBuffer.updateColor4("vReflectivityColor",e.PBRMaterial._scaledReflectivity,0)):this._uniformBuffer.updateColor4("vReflectivityColor",this._reflectivityColor,this._microSurface),this._uniformBuffer.updateColor3("vEmissiveColor",this._emissiveColor),this._uniformBuffer.updateColor3("vReflectionColor",this._reflectionColor),this._uniformBuffer.updateColor4("vAlbedoColor",this._albedoColor,this.alpha*i.visibility),this._lightingInfos.x=this._directIntensity,this._lightingInfos.y=this._emissiveIntensity,this._lightingInfos.z=this._environmentIntensity,this._lightingInfos.w=this._specularIntensity,this._uniformBuffer.updateVector4("vLightingIntensity",this._lightingInfos)}n.texturesEnabled&&(this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("albedoSampler",this._albedoTexture),this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled&&this._uniformBuffer.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled&&this._uniformBuffer.setTexture("opacitySampler",this._opacityTexture),l&&e.StandardMaterial.ReflectionTextureEnabled&&(o.LODBASEDMICROSFURACE?this._uniformBuffer.setTexture("reflectionSampler",l):(this._uniformBuffer.setTexture("reflectionSampler",l._lodTextureMid||l),this._uniformBuffer.setTexture("reflectionSamplerLow",l._lodTextureLow||l),this._uniformBuffer.setTexture("reflectionSamplerHigh",l._lodTextureHigh||l))),o.ENVIRONMENTBRDF&&this._uniformBuffer.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),h&&e.StandardMaterial.RefractionTextureEnabled&&(o.LODBASEDMICROSFURACE?this._uniformBuffer.setTexture("refractionSampler",h):(this._uniformBuffer.setTexture("refractionSampler",h._lodTextureMid||h),this._uniformBuffer.setTexture("refractionSamplerLow",h._lodTextureLow||h),this._uniformBuffer.setTexture("refractionSamplerHigh",h._lodTextureHigh||h))),this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled&&this._uniformBuffer.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled&&this._uniformBuffer.setTexture("lightmapSampler",this._lightmapTexture),e.StandardMaterial.SpecularTextureEnabled&&(this._metallicTexture?this._uniformBuffer.setTexture("reflectivitySampler",this._metallicTexture):this._reflectivityTexture&&this._uniformBuffer.setTexture("reflectivitySampler",this._reflectivityTexture),this._microSurfaceTexture&&this._uniformBuffer.setTexture("microSurfaceSampler",this._microSurfaceTexture)),this._bumpTexture&&n.getEngine().getCaps().standardDerivatives&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap&&this._uniformBuffer.setTexture("bumpSampler",this._bumpTexture)),e.MaterialHelper.BindClipPlane(this._activeEffect,n),n.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor);var f=n._forcedViewPosition?n._forcedViewPosition:n._mirroredCameraPosition?n._mirroredCameraPosition:n.activeCamera.globalPosition,d=n.useRightHandedSystem===(null!=n._mirroredCameraPosition);s.setFloat4("vEyePosition",f.x,f.y,f.z,d?-1:1),s.setColor3("vAmbientColor",this._globalAmbientColor)}!a&&this.isFrozen||(n.lightsEnabled&&!this._disableLighting&&e.MaterialHelper.BindLights(n,i,this._activeEffect,o,this._maxSimultaneousLights,this._usePhysicalLightFalloff),(n.fogEnabled&&i.applyFog&&n.fogMode!==e.Scene.FOGMODE_NONE||l)&&this.bindView(s),e.MaterialHelper.BindFogParameters(n,i,this._activeEffect),o.NUM_MORPH_INFLUENCERS&&e.MaterialHelper.BindMorphTargetParameters(i,this._activeEffect),this._imageProcessingConfiguration.bind(this._activeEffect),e.MaterialHelper.BindLogDepth(o,this._activeEffect,n)),this._uniformBuffer.update(),this._afterBind(i)}}},r.prototype.getAnimatables=function(){var e=[];return this._albedoTexture&&this._albedoTexture.animations&&this._albedoTexture.animations.length>0&&e.push(this._albedoTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._metallicTexture&&this._metallicTexture.animations&&this._metallicTexture.animations.length>0?e.push(this._metallicTexture):this._reflectivityTexture&&this._reflectivityTexture.animations&&this._reflectivityTexture.animations.length>0&&e.push(this._reflectivityTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),e},r.prototype._getReflectionTexture=function(){return this._reflectionTexture?this._reflectionTexture:this.getScene().environmentTexture},r.prototype._getRefractionTexture=function(){return this._refractionTexture?this._refractionTexture:this._linkRefractionWithTransparency?this.getScene().environmentTexture:null},r.prototype.dispose=function(e,t){t&&(this._albedoTexture&&this._albedoTexture.dispose(),this._ambientTexture&&this._ambientTexture.dispose(),this._opacityTexture&&this._opacityTexture.dispose(),this._reflectionTexture&&this._reflectionTexture.dispose(),this._environmentBRDFTexture&&this.getScene()._environmentBRDFTexture!==this._environmentBRDFTexture&&this._environmentBRDFTexture.dispose(),this._emissiveTexture&&this._emissiveTexture.dispose(),this._metallicTexture&&this._metallicTexture.dispose(),this._reflectivityTexture&&this._reflectivityTexture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._lightmapTexture&&this._lightmapTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose()),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),i.prototype.dispose.call(this,e,t)},r._scaledReflectivity=new e.Color3,__decorate([e.serializeAsImageProcessingConfiguration()],r.prototype,"_imageProcessingConfiguration",void 0),__decorate([e.serialize()],r.prototype,"useLogarithmicDepth",null),__decorate([e.serialize()],r.prototype,"transparencyMode",null),r})(e.PushMaterial);e.PBRBaseMaterial=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var i=(function(t){function i(i,r){var n=t.call(this,i,r)||this;return n.maxSimultaneousLights=4,n.disableLighting=!1,n.invertNormalMapX=!1,n.invertNormalMapY=!1,n.emissiveColor=new e.Color3(0,0,0),n.occlusionStrength=1,n._transparencyMode=e.PBRMaterial.PBRMATERIAL_OPAQUE,n._useAlphaFromAlbedoTexture=!0,n._useAmbientInGrayScale=!0,n}return __extends(i,t),Object.defineProperty(i.prototype,"doubleSided",{get:function(){return this._twoSidedLighting},set:function(e){this._twoSidedLighting!==e&&(this._twoSidedLighting=e,this.backFaceCulling=!e,this._markAllSubMeshesAsTexturesDirty())},enumerable:!0,configurable:!0}),i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this.environmentTexture&&e.push(this.environmentTexture),this.normalTexture&&e.push(this.normalTexture),this.emissiveTexture&&e.push(this.emissiveTexture),this.occlusionTexture&&e.push(this.occlusionTexture),e},i.prototype.getClassName=function(){return"PBRBaseSimpleMaterial"},__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectionTexture")],i.prototype,"environmentTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapX",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapY",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_bumpTexture")],i.prototype,"normalTexture",void 0),__decorate([e.serializeAsColor3("emissive"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"emissiveColor",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"emissiveTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_ambientTextureStrength")],i.prototype,"occlusionStrength",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_ambientTexture")],i.prototype,"occlusionTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_alphaCutOff")],i.prototype,"alphaCutOff",void 0),__decorate([e.serialize()],i.prototype,"doubleSided",null),i})(e.PBRBaseMaterial);t.PBRBaseSimpleMaterial=i})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r){var n=t.call(this,i,r)||this;return n.directIntensity=1,n.emissiveIntensity=1,n.environmentIntensity=1,n.specularIntensity=1,n.disableBumpMap=!1,n.ambientTextureStrength=1,n.ambientColor=new e.Color3(0,0,0),n.albedoColor=new e.Color3(1,1,1),n.reflectivityColor=new e.Color3(1,1,1),n.reflectionColor=new e.Color3(1,1,1),n.emissiveColor=new e.Color3(0,0,0),n.microSurface=1,n.indexOfRefraction=.66,n.invertRefractionY=!1,n.linkRefractionWithTransparency=!1,n.useLightmapAsShadowmap=!1,n.useAlphaFromAlbedoTexture=!1,n.forceAlphaTest=!1,n.alphaCutOff=.4,n.useSpecularOverAlpha=!0,n.useMicroSurfaceFromReflectivityMapAlpha=!1,n.useRoughnessFromMetallicTextureAlpha=!0,n.useRoughnessFromMetallicTextureGreen=!1,n.useMetallnessFromMetallicTextureBlue=!1,n.useAmbientOcclusionFromMetallicTextureRed=!1,n.useAmbientInGrayScale=!1,n.useAutoMicroSurfaceFromReflectivityMap=!1,n.usePhysicalLightFalloff=!0,n.useRadianceOverAlpha=!0,n.useParallax=!1,n.useParallaxOcclusion=!1,n.parallaxScaleBias=.05,n.disableLighting=!1,n.forceIrradianceInFragment=!1,n.maxSimultaneousLights=4,n.invertNormalMapX=!1,n.invertNormalMapY=!1,n.twoSidedLighting=!1,n.useAlphaFresnel=!1,n.environmentBRDFTexture=null,n.forceNormalForward=!1,n._environmentBRDFTexture=e.TextureTools.GetEnvironmentBRDFTexture(r),n}return __extends(i,t),Object.defineProperty(i,"PBRMATERIAL_OPAQUE",{get:function(){return this._PBRMATERIAL_OPAQUE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"PBRMATERIAL_ALPHATEST",{get:function(){return this._PBRMATERIAL_ALPHATEST},enumerable:!0,configurable:!0}),Object.defineProperty(i,"PBRMATERIAL_ALPHABLEND",{get:function(){return this._PBRMATERIAL_ALPHABLEND},enumerable:!0,configurable:!0}),Object.defineProperty(i,"PBRMATERIAL_ALPHATESTANDBLEND",{get:function(){return this._PBRMATERIAL_ALPHATESTANDBLEND},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this._imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorCurves",{get:function(){return this._imageProcessingConfiguration.colorCurves},set:function(e){this._imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"PBRMaterial"},i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this._albedoTexture&&e.push(this._albedoTexture),this._ambientTexture&&e.push(this._ambientTexture),this._opacityTexture&&e.push(this._opacityTexture),this._reflectionTexture&&e.push(this._reflectionTexture),this._emissiveTexture&&e.push(this._emissiveTexture),this._reflectivityTexture&&e.push(this._reflectivityTexture),this._metallicTexture&&e.push(this._metallicTexture),this._microSurfaceTexture&&e.push(this._microSurfaceTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),this._refractionTexture&&e.push(this._refractionTexture),e},i.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this._albedoTexture===e||(this._ambientTexture===e||(this._opacityTexture===e||(this._reflectionTexture===e||(this._reflectivityTexture===e||(this._metallicTexture===e||(this._microSurfaceTexture===e||(this._bumpTexture===e||(this._lightmapTexture===e||this._refractionTexture===e)))))))))},i.prototype.clone=function(t){var r=this,n=e.SerializationHelper.Clone((function(){return new i(t,r.getScene())}),this);return n.id=t,n.name=t,n},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.PBRMaterial",t},i.Parse=function(t,r,n){return e.SerializationHelper.Parse((function(){return new i(t.name,r)}),t,r,n)},i._PBRMATERIAL_OPAQUE=0,i._PBRMATERIAL_ALPHATEST=1,i._PBRMATERIAL_ALPHABLEND=2,i._PBRMATERIAL_ALPHATESTANDBLEND=3,__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"directIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"emissiveIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"environmentIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"specularIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"disableBumpMap",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"albedoTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"ambientTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"ambientTextureStrength",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"reflectivityTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"metallicTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"metallic",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"roughness",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"microSurfaceTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty",null)],i.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("albedo"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"albedoColor",void 0),__decorate([e.serializeAsColor3("reflectivity"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"reflectivityColor",void 0),__decorate([e.serializeAsColor3("reflection"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"reflectionColor",void 0),__decorate([e.serializeAsColor3("emissive"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"emissiveColor",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"microSurface",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"indexOfRefraction",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertRefractionY",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"linkRefractionWithTransparency",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useAlphaFromAlbedoTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"forceAlphaTest",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"alphaCutOff",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useRoughnessFromMetallicTextureAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useRoughnessFromMetallicTextureGreen",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useMetallnessFromMetallicTextureBlue",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useAmbientInGrayScale",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"usePhysicalLightFalloff",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useRadianceOverAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useParallax",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"forceIrradianceInFragment",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapX",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapY",void 0), __decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"twoSidedLighting",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useAlphaFresnel",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"environmentBRDFTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"forceNormalForward",void 0),i})(e.PBRBaseMaterial);e.PBRMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i){var r=t.call(this,e,i)||this;return r._useRoughnessFromMetallicTextureAlpha=!1,r._useRoughnessFromMetallicTextureGreen=!0,r._useMetallnessFromMetallicTextureBlue=!0,r}return __extends(i,t),i.prototype.getClassName=function(){return"PBRMetallicRoughnessMaterial"},i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this.baseTexture&&e.push(this.baseTexture),this.metallicRoughnessTexture&&e.push(this.metallicRoughnessTexture),e},i.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this.baseTexture===e||this.metallicRoughnessTexture===e)},i.prototype.clone=function(t){var r=this,n=e.SerializationHelper.Clone((function(){return new i(t,r.getScene())}),this);return n.id=t,n.name=t,n},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.PBRMetallicRoughnessMaterial",t},i.Parse=function(t,r,n){return e.SerializationHelper.Parse((function(){return new i(t.name,r)}),t,r,n)},__decorate([e.serializeAsColor3(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoColor")],i.prototype,"baseColor",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],i.prototype,"baseTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"metallic",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"roughness",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_metallicTexture")],i.prototype,"metallicRoughnessTexture",void 0),i})(e.Internals.PBRBaseSimpleMaterial);e.PBRMetallicRoughnessMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i){var r=t.call(this,e,i)||this;return r._useMicroSurfaceFromReflectivityMapAlpha=!0,r}return __extends(i,t),i.prototype.getClassName=function(){return"PBRSpecularGlossinessMaterial"},i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this.diffuseTexture&&e.push(this.diffuseTexture),this.specularGlossinessTexture&&e.push(this.specularGlossinessTexture),e},i.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this.diffuseTexture===e||this.specularGlossinessTexture===e)},i.prototype.clone=function(t){var r=this,n=e.SerializationHelper.Clone((function(){return new i(t,r.getScene())}),this);return n.id=t,n.name=t,n},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.PBRSpecularGlossinessMaterial",t},i.Parse=function(t,r,n){return e.SerializationHelper.Parse((function(){return new i(t.name,r)}),t,r,n)},__decorate([e.serializeAsColor3("diffuse"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoColor")],i.prototype,"diffuseColor",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],i.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsColor3("specular"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectivityColor")],i.prototype,"specularColor",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_microSurface")],i.prototype,"glossiness",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectivityTexture")],i.prototype,"specularGlossinessTexture",void 0),i})(e.Internals.PBRBaseSimpleMaterial);e.PBRSpecularGlossinessMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){e.CameraInputTypes={};var t=(function(){function t(e){this.attached={},this.camera=e,this.checkInputs=function(){}}return t.prototype.add=function(t){var i=t.getSimpleName();if(this.attached[i])return void e.Tools.Warn("camera input of type "+i+" already exists on camera");this.attached[i]=t,t.camera=this.camera,t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t))),this.attachedElement&&t.attachControl(this.attachedElement)},t.prototype.remove=function(e){for(var t in this.attached){var i=this.attached[t];i===e&&(i.detachControl(this.attachedElement),i.camera=null,delete this.attached[t],this.rebuildInputCheck())}},t.prototype.removeByType=function(e){for(var t in this.attached){var i=this.attached[t];i.getClassName()===e&&(i.detachControl(this.attachedElement),i.camera=null,delete this.attached[t],this.rebuildInputCheck())}},t.prototype._addCheckInputs=function(e){var t=this.checkInputs;return function(){t(),e()}},t.prototype.attachInput=function(e){this.attachedElement&&e.attachControl(this.attachedElement,this.noPreventDefault)},t.prototype.attachElement=function(t,i){if(void 0===i&&(i=!1),!this.attachedElement){i=!e.Camera.ForceAttachControlToAlwaysPreventDefault&&i,this.attachedElement=t,this.noPreventDefault=i;for(var r in this.attached)this.attached[r].attachControl(t,i)}},t.prototype.detachElement=function(e,t){if(void 0===t&&(t=!1),this.attachedElement===e){for(var i in this.attached)this.attached[i].detachControl(e),t&&(this.attached[i].camera=null);this.attachedElement=null}},t.prototype.rebuildInputCheck=function(){this.checkInputs=function(){};for(var e in this.attached){var t=this.attached[e];t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t)))}},t.prototype.clear=function(){this.attachedElement&&this.detachElement(this.attachedElement,!0),this.attached={},this.attachedElement=null,this.checkInputs=function(){}},t.prototype.serialize=function(t){var i={};for(var r in this.attached){var n=this.attached[r],o=e.SerializationHelper.Serialize(n);i[n.getClassName()]=o}t.inputsmgr=i},t.prototype.parse=function(t){var i=t.inputsmgr;if(i){this.clear();for(var r in i){var n=e.CameraInputTypes[r];if(n){var o=i[r],s=e.SerializationHelper.Parse((function(){return new n}),o,null);this.add(s)}}}else for(var r in this.attached){var n=e.CameraInputTypes[this.attached[r].getClassName()];if(n){var s=e.SerializationHelper.Parse((function(){return new n}),t,null);this.remove(this.attached[r]),this.add(s)}}},t})();e.CameraInputsManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){void 0===e&&(e=!0),this.touchEnabled=e,this.buttons=[0,1,2],this.angularSensibility=2e3,this.previousPosition=null}return t.prototype.attachControl=function(t,i){var r=this,n=this.camera.getEngine();this._pointerInput||(this._pointerInput=function(o,s){var a=o.event;if(!n.isInVRExclusivePointerMode&&(r.touchEnabled||"touch"!==a.pointerType)&&(o.type===e.PointerEventTypes.POINTERMOVE||-1!==r.buttons.indexOf(a.button))){var l=a.srcElement||a.target;if(o.type===e.PointerEventTypes.POINTERDOWN&&l){try{l.setPointerCapture(a.pointerId)}catch(e){}r.previousPosition={x:a.clientX,y:a.clientY},i||(a.preventDefault(),t.focus())}else if(o.type===e.PointerEventTypes.POINTERUP&&l){try{l.releasePointerCapture(a.pointerId)}catch(e){}r.previousPosition=null,i||a.preventDefault()}else if(o.type===e.PointerEventTypes.POINTERMOVE){if(!r.previousPosition||n.isPointerLock)return;var h=a.clientX-r.previousPosition.x,u=a.clientY-r.previousPosition.y;r.camera.getScene().useRightHandedSystem?r.camera.cameraRotation.y-=h/r.angularSensibility:r.camera.cameraRotation.y+=h/r.angularSensibility,r.camera.cameraRotation.x+=u/r.angularSensibility,r.previousPosition={x:a.clientX,y:a.clientY},i||a.preventDefault()}}}),this._onMouseMove=function(e){if(n.isPointerLock&&!n.isInVRExclusivePointerMode){var t=e.movementX||e.mozMovementX||e.webkitMovementX||e.msMovementX||0,o=e.movementY||e.mozMovementY||e.webkitMovementY||e.msMovementY||0;r.camera.getScene().useRightHandedSystem?r.camera.cameraRotation.y-=t/r.angularSensibility:r.camera.cameraRotation.y+=t/r.angularSensibility,r.camera.cameraRotation.x+=o/r.angularSensibility,r.previousPosition=null,i||e.preventDefault()}},this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,e.PointerEventTypes.POINTERDOWN|e.PointerEventTypes.POINTERUP|e.PointerEventTypes.POINTERMOVE),t.addEventListener("mousemove",this._onMouseMove,!1)},t.prototype.detachControl=function(e){this._observer&&e&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._onMouseMove&&e.removeEventListener("mousemove",this._onMouseMove),this._observer=null,this._onMouseMove=null,this.previousPosition=null)},t.prototype.getClassName=function(){return"FreeCameraMouseInput"},t.prototype.getSimpleName=function(){return"mouse"},__decorate([e.serialize()],t.prototype,"buttons",void 0),__decorate([e.serialize()],t.prototype,"angularSensibility",void 0),t})();e.FreeCameraMouseInput=t,e.CameraInputTypes.FreeCameraMouseInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._keys=new Array,this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39]}return t.prototype.attachControl=function(t,i){var r=this;this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){r._keys=[]})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(t){var n=t.event;if(t.type===e.KeyboardEventTypes.KEYDOWN){if(-1!==r.keysUp.indexOf(n.keyCode)||-1!==r.keysDown.indexOf(n.keyCode)||-1!==r.keysLeft.indexOf(n.keyCode)||-1!==r.keysRight.indexOf(n.keyCode)){var o=r._keys.indexOf(n.keyCode);-1===o&&r._keys.push(n.keyCode),i||n.preventDefault()}}else if(-1!==r.keysUp.indexOf(n.keyCode)||-1!==r.keysDown.indexOf(n.keyCode)||-1!==r.keysLeft.indexOf(n.keyCode)||-1!==r.keysRight.indexOf(n.keyCode)){var o=r._keys.indexOf(n.keyCode);o>=0&&r._keys.splice(o,1),i||n.preventDefault()}})))},t.prototype.detachControl=function(e){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys=[]},t.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var t=this.camera,i=0;i=0?this.rotation.y=-Math.atan(i.z/i.x)+Math.PI/2:this.rotation.y=-Math.atan(i.z/i.x)-Math.PI/2,this.rotation.z=0,isNaN(this.rotation.x)&&(this.rotation.x=0),isNaN(this.rotation.y)&&(this.rotation.y=0),isNaN(this.rotation.z)&&(this.rotation.z=0),this.rotationQuaternion&&e.Quaternion.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)},i.prototype.getTarget=function(){return this._currentTarget},i.prototype._decideIfNeedsToMove=function(){return Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},i.prototype._updatePosition=function(){if(this.parent)return this.parent.getWorldMatrix().invertToRef(e.Tmp.Matrix[0]),e.Vector3.TransformNormalToRef(this.cameraDirection,e.Tmp.Matrix[0],e.Tmp.Vector3[0]),void this.position.addInPlace(e.Tmp.Vector3[0]);this.position.addInPlace(this.cameraDirection)},i.prototype._checkInputs=function(){var i=this._decideIfNeedsToMove(),r=Math.abs(this.cameraRotation.x)>0||Math.abs(this.cameraRotation.y)>0;if(i&&this._updatePosition(),r){if(this.rotation.x+=this.cameraRotation.x,this.rotation.y+=this.cameraRotation.y,this.rotationQuaternion){this.rotation.lengthSquared()&&e.Quaternion.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)}if(!this.noRotationConstraint){var n=Math.PI/2*.95;this.rotation.x>n&&(this.rotation.x=n),this.rotation.x<-n&&(this.rotation.x=-n)}}i&&(Math.abs(this.cameraDirection.x)e.Engine.CollisionsEpsilon&&(o.position.addInPlace(o._diffPosition),o.onCollide&&r&&o.onCollide(r))})(i)},o.inputs=new e.FreeCameraInputsManager(o),o.inputs.addKeyboard().addMouse(),o}return __extends(i,t),Object.defineProperty(i.prototype,"angularSensibility",{get:function(){var e=this.inputs.attached.mouse;return e?e.angularSensibility:0},set:function(e){var t=this.inputs.attached.mouse;t&&(t.angularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUp:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDown:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysLeft:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRight:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!0,configurable:!0}),i.prototype.attachControl=function(e,t){this.inputs.attachElement(e,t)},i.prototype.detachControl=function(t){this.inputs.detachElement(t),this.cameraDirection=new e.Vector3(0,0,0),this.cameraRotation=new e.Vector2(0,0)},Object.defineProperty(i.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),i.prototype._collideWithWorld=function(t){var i;i=this.parent?e.Vector3.TransformCoordinates(this.position,this.parent.getWorldMatrix()):this.position,i.subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._collider||(this._collider=new e.Collider),this._collider.radius=this.ellipsoid,this._collider.collisionMask=this._collisionMask;var r=t;this.applyGravity&&(r=t.add(this.getScene().gravity)),this.getScene().collisionCoordinator.getNewPosition(this._oldPosition,r,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)},i.prototype._checkInputs=function(){this._localDirection||(this._localDirection=e.Vector3.Zero(),this._transformedDirection=e.Vector3.Zero()),this.inputs.checkInputs(),t.prototype._checkInputs.call(this)},i.prototype._decideIfNeedsToMove=function(){return this._needMoveForGravity||Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},i.prototype._updatePosition=function(){this.checkCollisions&&this.getScene().collisionsEnabled?this._collideWithWorld(this.cameraDirection):t.prototype._updatePosition.call(this)},i.prototype.dispose=function(){this.inputs.clear(),t.prototype.dispose.call(this)},i.prototype.getClassName=function(){return"FreeCamera"},__decorate([e.serializeAsVector3()],i.prototype,"ellipsoid",void 0),__decorate([e.serialize()],i.prototype,"checkCollisions",void 0),__decorate([e.serialize()],i.prototype,"applyGravity",void 0),i})(e.TargetCamera);e.FreeCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._keys=new Array,this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39],this.keysReset=[220],this.panningSensibility=50,this.zoomingSensibility=25,this.useAltToZoom=!0}return t.prototype.attachControl=function(t,i){var r=this;this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){r._keys=[]})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(t){var n=t.event;if(t.type===e.KeyboardEventTypes.KEYDOWN){if(r._ctrlPressed=n.ctrlKey,r._altPressed=n.altKey,-1!==r.keysUp.indexOf(n.keyCode)||-1!==r.keysDown.indexOf(n.keyCode)||-1!==r.keysLeft.indexOf(n.keyCode)||-1!==r.keysRight.indexOf(n.keyCode)||-1!==r.keysReset.indexOf(n.keyCode)){var o=r._keys.indexOf(n.keyCode);-1===o&&r._keys.push(n.keyCode),n.preventDefault&&(i||n.preventDefault())}}else if(-1!==r.keysUp.indexOf(n.keyCode)||-1!==r.keysDown.indexOf(n.keyCode)||-1!==r.keysLeft.indexOf(n.keyCode)||-1!==r.keysRight.indexOf(n.keyCode)||-1!==r.keysReset.indexOf(n.keyCode)){var o=r._keys.indexOf(n.keyCode);o>=0&&r._keys.splice(o,1),n.preventDefault&&(i||n.preventDefault())}})))},t.prototype.detachControl=function(e){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys=[]},t.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var e=this.camera,t=0;tn.camera.pinchToPanMaxDistance)n.pinchDeltaPercentage?n.camera.inertialRadiusOffset+=.001*(A-l)*n.camera.radius*n.pinchDeltaPercentage:n.camera.inertialRadiusOffset+=(A-l)/(n.pinchPrecision*((n.angularSensibilityX+n.angularSensibilityY)/2)*b),c.isPaning=!1,c.isPinching=!0;else if(r&&r.pointerId===y.pointerId&&0!==n.panningSensibility&&n.multiTouchPanning){if(!c.isPaning)return c.isPaning=!0,c.isPinching=!1,c.x=y.x,void(c.y=y.y);n.camera.inertialPanningX+=-(y.x-c.x)/n.panningSensibility,n.camera.inertialPanningY+=(y.y-c.y)/n.panningSensibility}r&&r.pointerId===p.pointerId&&(c.x=y.x,c.y=y.y)}l=A}}},this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,e.PointerEventTypes.POINTERDOWN|e.PointerEventTypes.POINTERUP|e.PointerEventTypes.POINTERMOVE|e.PointerEventTypes._POINTERDOUBLETAP),this._onContextMenu=function(e){e.preventDefault()},this.camera._useCtrlForPanning||t.addEventListener("contextmenu",this._onContextMenu,!1),this._onLostFocus=function(){s=a=null,l=0,c.isPaning=!1,c.isPinching=!1,u=0,r=null,h=0},this._onMouseMove=function(e){if(o.isPointerLock){var t=e.movementX||e.mozMovementX||e.webkitMovementX||e.msMovementX||0,r=e.movementY||e.mozMovementY||e.webkitMovementY||e.msMovementY||0;n.camera.inertialAlphaOffset-=t/n.angularSensibilityX,n.camera.inertialBetaOffset-=r/n.angularSensibilityY,i||e.preventDefault()}},this._onGestureStart=function(e){void 0!==window.MSGesture&&(n._MSGestureHandler||(n._MSGestureHandler=new MSGesture,n._MSGestureHandler.target=t),n._MSGestureHandler.addPointer(e.pointerId))},this._onGesture=function(e){n.camera.radius*=e.scale,e.preventDefault&&(i||(e.stopPropagation(),e.preventDefault()))},t.addEventListener("mousemove",this._onMouseMove,!1),t.addEventListener("MSPointerDown",this._onGestureStart,!1),t.addEventListener("MSGestureChange",this._onGesture,!1),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}])},t.prototype.detachControl=function(t){this._onLostFocus&&e.Tools.UnregisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]),t&&this._observer&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this._onContextMenu&&t.removeEventListener("contextmenu",this._onContextMenu),this._onMouseMove&&t.removeEventListener("mousemove",this._onMouseMove),this._onGestureStart&&t.removeEventListener("MSPointerDown",this._onGestureStart),this._onGesture&&t.removeEventListener("MSGestureChange",this._onGesture),this._isPanClick=!1,this.pinchInwards=!0,this._onMouseMove=null,this._onGestureStart=null,this._onGesture=null,this._MSGestureHandler=null,this._onLostFocus=null,this._onContextMenu=null)},t.prototype.getClassName=function(){return"ArcRotateCameraPointersInput"},t.prototype.getSimpleName=function(){return"pointers"},__decorate([e.serialize()],t.prototype,"buttons",void 0),__decorate([e.serialize()],t.prototype,"angularSensibilityX",void 0),__decorate([e.serialize()],t.prototype,"angularSensibilityY",void 0),__decorate([e.serialize()],t.prototype,"pinchPrecision",void 0),__decorate([e.serialize()],t.prototype,"pinchDeltaPercentage",void 0),__decorate([e.serialize()],t.prototype,"panningSensibility",void 0),__decorate([e.serialize()],t.prototype,"multiTouchPanning",void 0),__decorate([e.serialize()],t.prototype,"multiTouchPanAndZoom",void 0),t})();e.ArcRotateCameraPointersInput=t,e.CameraInputTypes.ArcRotateCameraPointersInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a){var l=t.call(this,i,e.Vector3.Zero(),a)||this;return l.inertialAlphaOffset=0,l.inertialBetaOffset=0,l.inertialRadiusOffset=0,l.lowerAlphaLimit=null,l.upperAlphaLimit=null,l.lowerBetaLimit=.01,l.upperBetaLimit=Math.PI,l.lowerRadiusLimit=null,l.upperRadiusLimit=null,l.inertialPanningX=0,l.inertialPanningY=0,l.pinchToPanMaxDistance=20,l.panningDistanceLimit=null,l.panningOriginTarget=e.Vector3.Zero(),l.panningInertia=.9,l.zoomOnFactor=1,l.targetScreenOffset=e.Vector2.Zero(),l.allowUpsideDown=!0,l._viewMatrix=new e.Matrix,l.panningAxis=new e.Vector3(1,1,0),l.onMeshTargetChangedObservable=new e.Observable,l.checkCollisions=!1,l.collisionRadius=new e.Vector3(.5,.5,.5),l._previousPosition=e.Vector3.Zero(),l._collisionVelocity=e.Vector3.Zero(),l._newPosition=e.Vector3.Zero(),l._onCollisionPositionChange=function(t,i,r){void 0===r&&(r=null),l.getScene().workerCollisions&&l.checkCollisions&&i.multiplyInPlace(l._collider.radius),r?(l.setPosition(i),l.onCollide&&l.onCollide(r)):l._previousPosition.copyFrom(l.position);var n=Math.cos(l.alpha),o=Math.sin(l.alpha),s=Math.cos(l.beta),a=Math.sin(l.beta);0===a&&(a=1e-4);var h=l._getTargetPosition();h.addToRef(new e.Vector3(l.radius*n*a,l.radius*s,l.radius*o*a),l._newPosition),l.position.copyFrom(l._newPosition);var u=l.upVector;l.allowUpsideDown&&l.beta<0&&(u=u.clone(),u=u.negate()),e.Matrix.LookAtLHToRef(l.position,h,u,l._viewMatrix),l._viewMatrix.m[12]+=l.targetScreenOffset.x,l._viewMatrix.m[13]+=l.targetScreenOffset.y,l._collisionTriggered=!1},l._target=e.Vector3.Zero(),s&&l.setTarget(s),l.alpha=r,l.beta=n,l.radius=o,l.getViewMatrix(),l.inputs=new e.ArcRotateCameraInputsManager(l),l.inputs.addKeyboard().addMouseWheel().addPointers(),l}return __extends(i,t),Object.defineProperty(i.prototype,"target",{get:function(){return this._target},set:function(e){this.setTarget(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"angularSensibilityX",{get:function(){var e=this.inputs.attached.pointers;return e?e.angularSensibilityX:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.angularSensibilityX=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"angularSensibilityY",{get:function(){var e=this.inputs.attached.pointers;return e?e.angularSensibilityY:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.angularSensibilityY=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"pinchPrecision",{get:function(){var e=this.inputs.attached.pointers;return e?e.pinchPrecision:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.pinchPrecision=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"pinchDeltaPercentage",{get:function(){var e=this.inputs.attached.pointers;return e?e.pinchDeltaPercentage:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.pinchDeltaPercentage=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"panningSensibility",{get:function(){var e=this.inputs.attached.pointers;return e?e.panningSensibility:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.panningSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUp:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDown:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysLeft:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRight:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"wheelPrecision",{get:function(){var e=this.inputs.attached.mousewheel;return e?e.wheelPrecision:0},set:function(e){var t=this.inputs.attached.mousewheel;t&&(t.wheelPrecision=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"wheelDeltaPercentage",{get:function(){var e=this.inputs.attached.mousewheel;return e?e.wheelDeltaPercentage:0},set:function(e){var t=this.inputs.attached.mousewheel;t&&(t.wheelDeltaPercentage=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"bouncingBehavior",{get:function(){return this._bouncingBehavior},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"useBouncingBehavior",{get:function(){return null!=this._bouncingBehavior},set:function(t){t!==this.useBouncingBehavior&&(t?(this._bouncingBehavior=new e.BouncingBehavior,this.addBehavior(this._bouncingBehavior)):this._bouncingBehavior&&(this.removeBehavior(this._bouncingBehavior),this._bouncingBehavior=null))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"framingBehavior",{get:function(){return this._framingBehavior},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"useFramingBehavior",{get:function(){return null!=this._framingBehavior},set:function(t){t!==this.useFramingBehavior&&(t?(this._framingBehavior=new e.FramingBehavior,this.addBehavior(this._framingBehavior)):this._framingBehavior&&(this.removeBehavior(this._framingBehavior),this._framingBehavior=null))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"autoRotationBehavior",{get:function(){return this._autoRotationBehavior},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"useAutoRotationBehavior",{get:function(){return null!=this._autoRotationBehavior},set:function(t){t!==this.useAutoRotationBehavior&&(t?(this._autoRotationBehavior=new e.AutoRotationBehavior,this.addBehavior(this._autoRotationBehavior)):this._autoRotationBehavior&&(this.removeBehavior(this._autoRotationBehavior),this._autoRotationBehavior=null))},enumerable:!0,configurable:!0}),i.prototype._initCache=function(){t.prototype._initCache.call(this),this._cache._target=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.alpha=void 0,this._cache.beta=void 0,this._cache.radius=void 0,this._cache.targetScreenOffset=e.Vector2.Zero()},i.prototype._updateCache=function(e){e||t.prototype._updateCache.call(this),this._cache._target.copyFrom(this._getTargetPosition()),this._cache.alpha=this.alpha,this._cache.beta=this.beta,this._cache.radius=this.radius,this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset)},i.prototype._getTargetPosition=function(){if(this._targetHost&&this._targetHost.getAbsolutePosition){var e=this._targetHost.getAbsolutePosition();this._targetBoundingCenter?e.addToRef(this._targetBoundingCenter,this._target):this._target.copyFrom(e)}var t=this._getLockedTargetPosition();return t||this._target},i.prototype.storeState=function(){return this._storedAlpha=this.alpha,this._storedBeta=this.beta,this._storedRadius=this.radius,this._storedTarget=this._getTargetPosition().clone(),t.prototype.storeState.call(this)},i.prototype._restoreStateValues=function(){return!!t.prototype._restoreStateValues.call(this)&&(this.alpha=this._storedAlpha,this.beta=this._storedBeta,this.radius=this._storedRadius,this.setTarget(this._storedTarget.clone()),this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0,!0)},i.prototype._isSynchronizedViewMatrix=function(){return!!t.prototype._isSynchronizedViewMatrix.call(this)&&(this._cache._target.equals(this._getTargetPosition())&&this._cache.alpha===this.alpha&&this._cache.beta===this.beta&&this._cache.radius===this.radius&&this._cache.targetScreenOffset.equals(this.targetScreenOffset))},i.prototype.attachControl=function(e,t,i,r){var n=this;void 0===i&&(i=!0),void 0===r&&(r=2),this._useCtrlForPanning=i,this._panningMouseButton=r,this.inputs.attachElement(e,t),this._reset=function(){n.inertialAlphaOffset=0,n.inertialBetaOffset=0,n.inertialRadiusOffset=0,n.inertialPanningX=0,n.inertialPanningY=0}},i.prototype.detachControl=function(e){this.inputs.detachElement(e),this._reset&&this._reset()},i.prototype._checkInputs=function(){if(!this._collisionTriggered){if(this.inputs.checkInputs(),0===this.inertialAlphaOffset&&0===this.inertialBetaOffset&&0===this.inertialRadiusOffset||(this.getScene().useRightHandedSystem?this.alpha-=this.beta<=0?-this.inertialAlphaOffset:this.inertialAlphaOffset:this.alpha+=this.beta<=0?-this.inertialAlphaOffset:this.inertialAlphaOffset,this.beta+=this.inertialBetaOffset,this.radius-=this.inertialRadiusOffset,this.inertialAlphaOffset*=this.inertia,this.inertialBetaOffset*=this.inertia,this.inertialRadiusOffset*=this.inertia,Math.abs(this.inertialAlphaOffset)Math.PI&&(this.beta=this.beta-2*Math.PI):this.betathis.upperBetaLimit&&(this.beta=this.upperBetaLimit),this.lowerAlphaLimit&&this.alphathis.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),this.lowerRadiusLimit&&this.radiusthis.upperRadiusLimit&&(this.radius=this.upperRadiusLimit)},i.prototype.rebuildAnglesAndRadius=function(){var e=this.position.subtract(this._getTargetPosition());this.radius=e.length(),0===this.radius&&(this.radius=1e-4),this.alpha=Math.acos(e.x/Math.sqrt(Math.pow(e.x,2)+Math.pow(e.z,2))),e.z<0&&(this.alpha=2*Math.PI-this.alpha),this.beta=Math.acos(e.y/this.radius),this._checkLimits()},i.prototype.setPosition=function(e){this.position.equals(e)||(this.position.copyFrom(e),this.rebuildAnglesAndRadius())},i.prototype.setTarget=function(e,t,i){if(void 0===t&&(t=!1),void 0===i&&(i=!1),e.getBoundingInfo)this._targetBoundingCenter=t?e.getBoundingInfo().boundingBox.centerWorld.clone():null,this._targetHost=e,this._target=this._getTargetPosition(),this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);else{var r=e,n=this._getTargetPosition();if(n&&!i&&n.equals(r))return;this._targetHost=null,this._target=r,this._targetBoundingCenter=null,this.onMeshTargetChangedObservable.notifyObservers(null)}this.rebuildAnglesAndRadius()},i.prototype._getViewMatrix=function(){var t=Math.cos(this.alpha),i=Math.sin(this.alpha),r=Math.cos(this.beta),n=Math.sin(this.beta);0===n&&(n=1e-4);var o=this._getTargetPosition();if(o.addToRef(new e.Vector3(this.radius*t*n,this.radius*r,this.radius*i*n),this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions)this._collider||(this._collider=new e.Collider),this._collider.radius=this.collisionRadius,this._newPosition.subtractToRef(this.position,this._collisionVelocity),this._collisionTriggered=!0,this.getScene().collisionCoordinator.getNewPosition(this.position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId);else{this.position.copyFrom(this._newPosition);var s=this.upVector;this.allowUpsideDown&&n<0&&(s=s.clone(),s=s.negate()),this.getScene().useRightHandedSystem?e.Matrix.LookAtRHToRef(this.position,o,s,this._viewMatrix):e.Matrix.LookAtLHToRef(this.position,o,s,this._viewMatrix),this._viewMatrix.m[12]+=this.targetScreenOffset.x,this._viewMatrix.m[13]+=this.targetScreenOffset.y}return this._currentTarget=o,this._viewMatrix},i.prototype.zoomOn=function(t,i){void 0===i&&(i=!1),t=t||this.getScene().meshes;var r=e.Mesh.MinMax(t),n=e.Vector3.Distance(r.min,r.max);this.radius=n*this.zoomOnFactor,this.focusOn({min:r.min,max:r.max,distance:n},i)},i.prototype.focusOn=function(t,i){void 0===i&&(i=!1);var r,n;if(void 0===t.min){var o=t||this.getScene().meshes;r=e.Mesh.MinMax(o),n=e.Vector3.Distance(r.min,r.max)}else{var s=t;r=s,n=s.distance}this._target=e.Mesh.Center(r),i||(this.maxZ=2*n)},i.prototype.createRigCamera=function(t,r){var n=0;switch(this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:case e.Camera.RIG_MODE_VR:n=this._cameraRigParams.stereoHalfAngle*(0===r?1:-1);break;case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:n=this._cameraRigParams.stereoHalfAngle*(0===r?-1:1)}var o=new i(t,this.alpha+n,this.beta,this.radius,this._target,this.getScene());return o._cameraRigParams={},o},i.prototype._updateRigCameras=function(){var i=this._rigCameras[0],r=this._rigCameras[1];switch(i.beta=r.beta=this.beta,i.radius=r.radius=this.radius,this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:case e.Camera.RIG_MODE_VR:i.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,r.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:i.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle,r.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle}t.prototype._updateRigCameras.call(this)},i.prototype.dispose=function(){this.inputs.clear(),t.prototype.dispose.call(this)},i.prototype.getClassName=function(){return"ArcRotateCamera"},__decorate([e.serialize()],i.prototype,"alpha",void 0),__decorate([e.serialize()],i.prototype,"beta",void 0),__decorate([e.serialize()],i.prototype,"radius",void 0),__decorate([e.serializeAsVector3("target")],i.prototype,"_target",void 0),__decorate([e.serialize()],i.prototype,"inertialAlphaOffset",void 0),__decorate([e.serialize()],i.prototype,"inertialBetaOffset",void 0),__decorate([e.serialize()],i.prototype,"inertialRadiusOffset",void 0),__decorate([e.serialize()],i.prototype,"lowerAlphaLimit",void 0),__decorate([e.serialize()],i.prototype,"upperAlphaLimit",void 0),__decorate([e.serialize()],i.prototype,"lowerBetaLimit",void 0),__decorate([e.serialize()],i.prototype,"upperBetaLimit",void 0),__decorate([e.serialize()],i.prototype,"lowerRadiusLimit",void 0),__decorate([e.serialize()],i.prototype,"upperRadiusLimit",void 0),__decorate([e.serialize()],i.prototype,"inertialPanningX",void 0),__decorate([e.serialize()],i.prototype,"inertialPanningY",void 0),__decorate([e.serialize()],i.prototype,"pinchToPanMaxDistance",void 0),__decorate([e.serialize()],i.prototype,"panningDistanceLimit",void 0),__decorate([e.serializeAsVector3()],i.prototype,"panningOriginTarget",void 0),__decorate([e.serialize()],i.prototype,"panningInertia",void 0),__decorate([e.serialize()],i.prototype,"zoomOnFactor",void 0),__decorate([e.serialize()],i.prototype,"allowUpsideDown",void 0),i})(e.TargetCamera);e.ArcRotateCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e){return t.call(this,e)||this}return __extends(i,t),i.prototype.addMouseWheel=function(){return this.add(new e.ArcRotateCameraMouseWheelInput),this},i.prototype.addPointers=function(){return this.add(new e.ArcRotateCameraPointersInput),this},i.prototype.addKeyboard=function(){return this.add(new e.ArcRotateCameraKeyboardMoveInput),this},i.prototype.addGamepad=function(){return this.add(new e.ArcRotateCameraGamepadInput),this},i.prototype.addVRDeviceOrientation=function(){return this.add(new e.ArcRotateCameraVRDeviceOrientationInput),this},i})(e.CameraInputsManager);e.ArcRotateCameraInputsManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n){var o=t.call(this,i,n)||this;return o.groundColor=new e.Color3(0,0,0),o.direction=r||e.Vector3.Up(),o}return __extends(i,t),i.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("vLightGround",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},i.prototype.getClassName=function(){return"HemisphericLight"},i.prototype.setDirectionToTarget=function(t){return this.direction=e.Vector3.Normalize(t.subtract(e.Vector3.Zero())),this.direction},i.prototype.getShadowGenerator=function(){return null},i.prototype.transferToEffect=function(t,i){var r=e.Vector3.Normalize(this.direction);return this._uniformBuffer.updateFloat4("vLightData",r.x,r.y,r.z,0,i),this._uniformBuffer.updateColor3("vLightGround",this.groundColor.scale(this.intensity),i),this},i.prototype._getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),this._worldMatrix},i.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_HEMISPHERICLIGHT},__decorate([e.serializeAsColor3()],i.prototype,"groundColor",void 0),__decorate([e.serializeAsVector3()],i.prototype,"direction",void 0),i})(e.Light);e.HemisphericLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(){var e=null!==t&&t.apply(this,arguments)||this;return e._needProjectionMatrixCompute=!0,e}return __extends(i,t),Object.defineProperty(i.prototype,"direction",{get:function(){return this._direction},set:function(e){this._direction=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"shadowMinZ",{get:function(){return this._shadowMinZ},set:function(e){this._shadowMinZ=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"shadowMaxZ",{get:function(){return this._shadowMaxZ},set:function(e){this._shadowMaxZ=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),i.prototype.computeTransformedInformation=function(){return!(!this.parent||!this.parent.getWorldMatrix)&&(this.transformedPosition||(this.transformedPosition=e.Vector3.Zero()),e.Vector3.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),this.direction&&(this.transformedDirection||(this.transformedDirection=e.Vector3.Zero()),e.Vector3.TransformNormalToRef(this.direction,this.parent.getWorldMatrix(),this.transformedDirection)),!0)},i.prototype.getDepthScale=function(){return 50},i.prototype.getShadowDirection=function(e){return this.transformedDirection?this.transformedDirection:this.direction},i.prototype.getAbsolutePosition=function(){return this.transformedPosition?this.transformedPosition:this.position},i.prototype.setDirectionToTarget=function(t){return this.direction=e.Vector3.Normalize(t.subtract(this.position)),this.direction},i.prototype.getRotation=function(){this.direction.normalize();var t=e.Vector3.Cross(this.direction,e.Axis.Y),i=e.Vector3.Cross(t,this.direction);return e.Vector3.RotationFromAxis(t,i,this.direction)},i.prototype.needCube=function(){return!1},i.prototype.needProjectionMatrixCompute=function(){return this._needProjectionMatrixCompute},i.prototype.forceProjectionMatrixCompute=function(){this._needProjectionMatrixCompute=!0},i.prototype._getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),e.Matrix.TranslationToRef(this.position.x,this.position.y,this.position.z,this._worldMatrix),this._worldMatrix},i.prototype.getDepthMinZ=function(e){return void 0!==this.shadowMinZ?this.shadowMinZ:e.minZ},i.prototype.getDepthMaxZ=function(e){return void 0!==this.shadowMaxZ?this.shadowMaxZ:e.maxZ},i.prototype.setShadowProjectionMatrix=function(e,t,i){return this.customProjectionMatrixBuilder?this.customProjectionMatrixBuilder(t,i,e):this._setDefaultShadowProjectionMatrix(e,t,i),this},__decorate([e.serializeAsVector3()],i.prototype,"position",void 0),__decorate([e.serializeAsVector3()],i.prototype,"direction",null),__decorate([e.serialize()],i.prototype,"shadowMinZ",null),__decorate([e.serialize()],i.prototype,"shadowMaxZ",null),i})(e.Light);e.ShadowLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i,r){var n=t.call(this,e,r)||this;return n._shadowAngle=Math.PI/2,n.position=i,n}return __extends(i,t),Object.defineProperty(i.prototype,"shadowAngle",{get:function(){return this._shadowAngle},set:function(e){this._shadowAngle=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"direction",{get:function(){return this._direction},set:function(e){var t=this.needCube();this._direction=e,this.needCube()!==t&&this._shadowGenerator&&this._shadowGenerator.recreateShadowMap()},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"PointLight"},i.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_POINTLIGHT},i.prototype.needCube=function(){return!this.direction},i.prototype.getShadowDirection=function(i){if(this.direction)return t.prototype.getShadowDirection.call(this,i);switch(i){case 0:return new e.Vector3(1,0,0);case 1:return new e.Vector3(-1,0,0);case 2:return new e.Vector3(0,-1,0);case 3:return new e.Vector3(0,1,0);case 4:return new e.Vector3(0,0,1);case 5:return new e.Vector3(0,0,-1)}return e.Vector3.Zero()},i.prototype._setDefaultShadowProjectionMatrix=function(t,i,r){var n=this.getScene().activeCamera;n&&e.Matrix.PerspectiveFovLHToRef(this.shadowAngle,1,this.getDepthMinZ(n),this.getDepthMaxZ(n),t)},i.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},i.prototype.transferToEffect=function(e,t){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,0,t),this):(this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,0,t),this)},__decorate([e.serialize()],i.prototype,"shadowAngle",null),i})(e.ShadowLight);e.PointLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i,r){var n=t.call(this,e,r)||this;return n._shadowFrustumSize=0,n._shadowOrthoScale=.5,n.autoUpdateExtends=!0,n._orthoLeft=Number.MAX_VALUE,n._orthoRight=Number.MIN_VALUE,n._orthoTop=Number.MIN_VALUE,n._orthoBottom=Number.MAX_VALUE,n.position=i.scale(-1),n.direction=i,n}return __extends(i,t),Object.defineProperty(i.prototype,"shadowFrustumSize",{get:function(){return this._shadowFrustumSize},set:function(e){this._shadowFrustumSize=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"shadowOrthoScale",{get:function(){return this._shadowOrthoScale},set:function(e){this._shadowOrthoScale=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"DirectionalLight"},i.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_DIRECTIONALLIGHT},i.prototype._setDefaultShadowProjectionMatrix=function(e,t,i){this.shadowFrustumSize>0?this._setDefaultFixedFrustumShadowProjectionMatrix(e,t):this._setDefaultAutoExtendShadowProjectionMatrix(e,t,i)},i.prototype._setDefaultFixedFrustumShadowProjectionMatrix=function(t,i){var r=this.getScene().activeCamera;r&&e.Matrix.OrthoLHToRef(this.shadowFrustumSize,this.shadowFrustumSize,void 0!==this.shadowMinZ?this.shadowMinZ:r.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:r.maxZ,t)},i.prototype._setDefaultAutoExtendShadowProjectionMatrix=function(t,i,r){var n=this.getScene().activeCamera;if(n){if(this.autoUpdateExtends||this._orthoLeft===Number.MAX_VALUE){var o=e.Vector3.Zero();this._orthoLeft=Number.MAX_VALUE,this._orthoRight=Number.MIN_VALUE,this._orthoTop=Number.MIN_VALUE,this._orthoBottom=Number.MAX_VALUE;for(var s=0;sthis._orthoRight&&(this._orthoRight=o.x),o.y>this._orthoTop&&(this._orthoTop=o.y)}}var c=this._orthoRight-this._orthoLeft,f=this._orthoTop-this._orthoBottom;e.Matrix.OrthoOffCenterLHToRef(this._orthoLeft-c*this.shadowOrthoScale,this._orthoRight+c*this.shadowOrthoScale,this._orthoBottom-f*this.shadowOrthoScale,this._orthoTop+f*this.shadowOrthoScale,void 0!==this.shadowMinZ?this.shadowMinZ:n.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:n.maxZ,t)}},i.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},i.prototype.transferToEffect=function(e,t){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z,1,t),this):(this._uniformBuffer.updateFloat4("vLightData",this.direction.x,this.direction.y,this.direction.z,1,t),this)},i.prototype.getDepthMinZ=function(e){return 1},i.prototype.getDepthMaxZ=function(e){return 1},__decorate([e.serialize()],i.prototype,"shadowFrustumSize",null),__decorate([e.serialize()],i.prototype,"shadowOrthoScale",null),__decorate([e.serialize()],i.prototype,"autoUpdateExtends",void 0),i})(e.ShadowLight);e.DirectionalLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i,r,n,o,s){var a=t.call(this,e,s)||this;return a.position=i,a.direction=r,a.angle=n,a.exponent=o,a}return __extends(i,t),Object.defineProperty(i.prototype,"angle",{get:function(){return this._angle},set:function(e){this._angle=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"shadowAngleScale",{get:function(){return this._shadowAngleScale},set:function(e){this._shadowAngleScale=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"SpotLight"},i.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_SPOTLIGHT},i.prototype._setDefaultShadowProjectionMatrix=function(t,i,r){var n=this.getScene().activeCamera;if(n){this._shadowAngleScale=this._shadowAngleScale||1;var o=this._shadowAngleScale*this._angle;e.Matrix.PerspectiveFovLHToRef(o,1,this.getDepthMinZ(n),this.getDepthMaxZ(n),t)}},i.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("vLightDirection",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},i.prototype.transferToEffect=function(t,i){var r ;return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,this.exponent,i),r=e.Vector3.Normalize(this.transformedDirection)):(this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,this.exponent,i),r=e.Vector3.Normalize(this.direction)),this._uniformBuffer.updateFloat4("vLightDirection",r.x,r.y,r.z,Math.cos(.5*this.angle),i),this},__decorate([e.serialize()],i.prototype,"angle",null),__decorate([e.serialize()],i.prototype,"shadowAngleScale",null),__decorate([e.serialize()],i.prototype,"exponent",void 0),i})(e.ShadowLight);e.SpotLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e,t,i){this.name=e,this.from=t,this.to=i}return e.prototype.clone=function(){return new e(this.name,this.from,this.to)},e})();e.AnimationRange=t;var i=(function(){function e(e,t,i){this.frame=e,this.action=t,this.onlyOnce=i,this.isDone=!1}return e})();e.AnimationEvent=i;var r=(function(){function t(e){this.path=e,this._onchange=new Array,this.value=0,this.animations=new Array}return t.prototype.getPoint=function(){var t=this.path.getPointAtLengthPosition(this.value);return new e.Vector3(t.x,0,t.y)},t.prototype.moveAhead=function(e){return void 0===e&&(e=.002),this.move(e),this},t.prototype.moveBack=function(e){return void 0===e&&(e=.002),this.move(-e),this},t.prototype.move=function(e){if(Math.abs(e)>1)throw"step size should be less than 1.";return this.value+=e,this.ensureLimits(),this.raiseOnChange(),this},t.prototype.ensureLimits=function(){for(;this.value>1;)this.value-=1;for(;this.value<0;)this.value+=1;return this},t.prototype.raiseOnChange=function(){var e=this;return this._onchange.forEach((function(t){return t(e)})),this},t.prototype.onchange=function(e){return this._onchange.push(e),this},t})();e.PathCursor=r;var n=(function(){function i(e,t,r,n,o,s){this.name=e,this.targetProperty=t,this.framePerSecond=r,this.dataType=n,this.loopMode=o,this.enableBlending=s,this._runtimeAnimations=new Array,this._events=new Array,this.blendingSpeed=.01,this._ranges={},this.targetPropertyPath=t.split("."),this.dataType=n,this.loopMode=void 0===o?i.ANIMATIONLOOPMODE_CYCLE:o}return i._PrepareAnimation=function(t,r,n,o,s,a,l,h){var u=void 0;if(!isNaN(parseFloat(s))&&isFinite(s)?u=i.ANIMATIONTYPE_FLOAT:s instanceof e.Quaternion?u=i.ANIMATIONTYPE_QUATERNION:s instanceof e.Vector3?u=i.ANIMATIONTYPE_VECTOR3:s instanceof e.Vector2?u=i.ANIMATIONTYPE_VECTOR2:s instanceof e.Color3?u=i.ANIMATIONTYPE_COLOR3:s instanceof e.Size&&(u=i.ANIMATIONTYPE_SIZE),void 0==u)return null;var c=new i(t,r,n,u,l),f=[{frame:0,value:s},{frame:o,value:a}];return c.setKeys(f),void 0!==h&&c.setEasingFunction(h),c},i.CreateAnimation=function(t,i,r,n){var o=new e.Animation(t+"Animation",t,r,i,e.Animation.ANIMATIONLOOPMODE_CONSTANT);return o.setEasingFunction(n),o},i.CreateAndStartAnimation=function(e,t,r,n,o,s,a,l,h,u){var c=i._PrepareAnimation(e,r,n,o,s,a,l,h);return c?t.getScene().beginDirectAnimation(t,[c],0,o,1===c.loopMode,1,u):null},i.CreateMergeAndStartAnimation=function(e,t,r,n,o,s,a,l,h,u){var c=i._PrepareAnimation(e,r,n,o,s,a,l,h);return c?(t.animations.push(c),t.getScene().beginAnimation(t,0,o,1===c.loopMode,1,u)):null},i.TransitionTo=function(e,t,i,r,n,o,s,a){if(void 0===a&&(a=null),s<=0)return i[e]=t,a&&a(),null;var l=n*(s/1e3);o.setKeys([{frame:0,value:i[e].clone?i[e].clone():i[e]},{frame:l,value:t}]),i.animations||(i.animations=[]),i.animations.push(o);var h=r.beginAnimation(i,0,l,!1);return h.onAnimationEnd=a,h},Object.defineProperty(i.prototype,"runtimeAnimations",{get:function(){return this._runtimeAnimations},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"hasRunningRuntimeAnimations",{get:function(){for(var e=0,t=this._runtimeAnimations;e=0;o--)this._keys[o].frame>=r&&this._keys[o].frame<=n&&this._keys.splice(o,1);this._ranges[e]=null}},i.prototype.getRange=function(e){return this._ranges[e]},i.prototype.getKeys=function(){return this._keys},i.prototype.getHighestFrame=function(){for(var e=0,t=0,i=this._keys.length;t=1&&(l=u.values[1]),u.values.length>=2&&(h=u.values[2]);break;case i.ANIMATIONTYPE_QUATERNION:if(r=e.Quaternion.FromArray(u.values),u.values.length>=8){var c=e.Quaternion.FromArray(u.values.slice(4,8));c.equals(e.Quaternion.Zero())||(l=c)}if(u.values.length>=12){var f=e.Quaternion.FromArray(u.values.slice(8,12));f.equals(e.Quaternion.Zero())||(h=f)}break;case i.ANIMATIONTYPE_MATRIX:r=e.Matrix.FromArray(u.values);break;case i.ANIMATIONTYPE_COLOR3:r=e.Color3.FromArray(u.values);break;case i.ANIMATIONTYPE_VECTOR3:default:r=e.Vector3.FromArray(u.values)}var d={};d.frame=u.frame,d.value=r,void 0!=l&&(d.inTangent=l),void 0!=h&&(d.outTangent=h),a.push(d)}if(o.setKeys(a),t.ranges)for(n=0;n-1&&this._animation.runtimeAnimations.splice(e,1)},t.prototype._getKeyValue=function(e){return"function"==typeof e?e():e},t.prototype._interpolate=function(t,i,r,n,o){if(r===e.Animation.ANIMATIONLOOPMODE_CONSTANT&&i>0)return o.clone?o.clone():o;this.currentFrame=t;var s=this._animation.getKeys(),a=Math.max(0,Math.min(s.length-1,Math.floor(s.length*(t-s[0].frame)/(s[s.length-1].frame-s[0].frame))-1));if(s[a].frame>=t)for(;a-1>=0&&s[a].frame>=t;)a--;for(var l=a;l=t){var u=s[l],c=this._getKeyValue(u.value),f=this._getKeyValue(h.value),d=void 0!==u.outTangent&&void 0!==h.inTangent,p=h.frame-u.frame,_=(t-u.frame)/p,m=this._animation.getEasingFunction();switch(null!=m&&(_=m.ease(_)),this._animation.dataType){case e.Animation.ANIMATIONTYPE_FLOAT:var g=d?this._animation.floatInterpolateFunctionWithTangents(c,u.outTangent*p,f,h.inTangent*p,_):this._animation.floatInterpolateFunction(c,f,_);switch(r){case e.Animation.ANIMATIONLOOPMODE_CYCLE:case e.Animation.ANIMATIONLOOPMODE_CONSTANT:return g;case e.Animation.ANIMATIONLOOPMODE_RELATIVE:return n*i+g}break;case e.Animation.ANIMATIONTYPE_QUATERNION:var v=d?this._animation.quaternionInterpolateFunctionWithTangents(c,u.outTangent.scale(p),f,h.inTangent.scale(p),_):this._animation.quaternionInterpolateFunction(c,f,_);switch(r){case e.Animation.ANIMATIONLOOPMODE_CYCLE:case e.Animation.ANIMATIONLOOPMODE_CONSTANT:return v;case e.Animation.ANIMATIONLOOPMODE_RELATIVE:return v.add(n.scale(i))}return v;case e.Animation.ANIMATIONTYPE_VECTOR3:var y=d?this._animation.vector3InterpolateFunctionWithTangents(c,u.outTangent.scale(p),f,h.inTangent.scale(p),_):this._animation.vector3InterpolateFunction(c,f,_);switch(r){case e.Animation.ANIMATIONLOOPMODE_CYCLE:case e.Animation.ANIMATIONLOOPMODE_CONSTANT:return y;case e.Animation.ANIMATIONLOOPMODE_RELATIVE:return y.add(n.scale(i))}case e.Animation.ANIMATIONTYPE_VECTOR2:var b=d?this._animation.vector2InterpolateFunctionWithTangents(c,u.outTangent.scale(p),f,h.inTangent.scale(p),_):this._animation.vector2InterpolateFunction(c,f,_);switch(r){case e.Animation.ANIMATIONLOOPMODE_CYCLE:case e.Animation.ANIMATIONLOOPMODE_CONSTANT:return b;case e.Animation.ANIMATIONLOOPMODE_RELATIVE:return b.add(n.scale(i))}case e.Animation.ANIMATIONTYPE_SIZE:switch(r){case e.Animation.ANIMATIONLOOPMODE_CYCLE:case e.Animation.ANIMATIONLOOPMODE_CONSTANT:return this._animation.sizeInterpolateFunction(c,f,_);case e.Animation.ANIMATIONLOOPMODE_RELATIVE:return this._animation.sizeInterpolateFunction(c,f,_).add(n.scale(i))}case e.Animation.ANIMATIONTYPE_COLOR3:switch(r){case e.Animation.ANIMATIONLOOPMODE_CYCLE:case e.Animation.ANIMATIONLOOPMODE_CONSTANT:return this._animation.color3InterpolateFunction(c,f,_);case e.Animation.ANIMATIONLOOPMODE_RELATIVE:return this._animation.color3InterpolateFunction(c,f,_).add(n.scale(i))}case e.Animation.ANIMATIONTYPE_MATRIX:switch(r){case e.Animation.ANIMATIONLOOPMODE_CYCLE:case e.Animation.ANIMATIONLOOPMODE_CONSTANT:if(e.Animation.AllowMatricesInterpolation)return this._animation.matrixInterpolateFunction(c,f,_);case e.Animation.ANIMATIONLOOPMODE_RELATIVE:return c}}break}}return this._getKeyValue(s[s.length-1].value)},t.prototype.setValue=function(t,i){void 0===i&&(i=!1);var r,n,o=this._animation.targetPropertyPath;if(o.length>1){for(var s=this._target[o[0]],a=1;at[t.length-1].frame&&(e=t[t.length-1].frame);var i=this._interpolate(e,0,this._animation.loopMode);this.setValue(i)},t.prototype._prepareForSpeedRatioChange=function(e){var t=this._previousDelay*(this._animation.framePerSecond*e)/1e3;this._ratioOffset=this._previousRatio-t},t.prototype.animate=function(t,i,r,n,o,s){void 0===s&&(s=!1);var a=this._animation.targetPropertyPath;if(!a||a.length<1)return this._stopped=!0,!1;var l=!0,h=this._animation.getKeys();if(0!==h[0].frame){var u={frame:0,value:h[0].value};h.splice(0,0,u)}(ih[h.length-1].frame)&&(i=h[0].frame),(rh[h.length-1].frame)&&(r=h[h.length-1].frame),i===r&&(i>h[0].frame?i--:ri&&d>f||i>r&&d>0,y=l?i+d%f:r,b=this._interpolate(y,v,this._animation.loopMode,c,p);this.setValue(b);for(var x=this._animation.getEvents(),T=0;T0&&y>=x[T].frame&&x[T].frame>=i||f<0&&y<=x[T].frame&&x[T].frame<=i){var A=x[T];A.isDone||(A.onlyOnce&&(x.splice(T,1),T--),A.isDone=!0,A.action())}else x[T].isDone&&!x[T].onlyOnce&&(x[T].isDone=!1);return l||(this._stopped=!0),l},t})();e.RuntimeAnimation=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t,i,r,n,o,s,a){void 0===i&&(i=0),void 0===r&&(r=100),void 0===n&&(n=!1),void 0===o&&(o=1),this.target=t,this.fromFrame=i,this.toFrame=r,this.loopAnimation=n,this.onAnimationEnd=s,this._localDelayOffset=null,this._pausedDelay=null,this._runtimeAnimations=new Array,this._paused=!1,this._speedRatio=1,this.animationStarted=!1,a&&this.appendAnimations(t,a),this._speedRatio=o,this._scene=e,e._activeAnimatables.push(this)}return Object.defineProperty(t.prototype,"speedRatio",{get:function(){return this._speedRatio},set:function(e){for(var t=0;t-1){for(var i=this._runtimeAnimations,r=i.length-1;r>=0;r--)"string"==typeof e&&i[r].animation.name!=e||(i[r].dispose(),i.splice(r,1));0==i.length&&(this._scene._activeAnimatables.splice(t,1),this.onAnimationEnd&&this.onAnimationEnd())}}else{var r=this._scene._activeAnimatables.indexOf(this);if(r>-1){this._scene._activeAnimatables.splice(r,1);for(var i=this._runtimeAnimations,r=0;r=.5?.5*(1-this.easeInCore(2*(1-t)))+.5:.5*this.easeInCore(2*t)},e._EASINGMODE_EASEIN=0,e._EASINGMODE_EASEOUT=1,e._EASINGMODE_EASEINOUT=2,e})();e.EasingFunction=t;var i=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e=Math.max(0,Math.min(1,e)),1-Math.sqrt(1-e*e)},t})(t);e.CircleEase=i;var r=(function(e){function t(t){void 0===t&&(t=1);var i=e.call(this)||this;return i.amplitude=t,i}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.amplitude);return Math.pow(e,3)-e*t*Math.sin(3.141592653589793*e)},t})(t);e.BackEase=r;var n=(function(e){function t(t,i){void 0===t&&(t=3),void 0===i&&(i=2);var r=e.call(this)||this;return r.bounces=t,r.bounciness=i,r}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.bounces),i=this.bounciness;i<=1&&(i=1.001);var r=Math.pow(i,t),n=1-i,o=(1-r)/n+.5*r,s=e*o,a=Math.log(-s*(1-i)+1)/Math.log(i),l=Math.floor(a),h=l+1,u=(1-Math.pow(i,l))/(n*o),c=(1-Math.pow(i,h))/(n*o),f=.5*(u+c),d=e-f,p=f-u;return-Math.pow(1/i,t-l)/(p*p)*(d-p)*(d+p)},t})(t);e.BounceEase=n;var o=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e},t})(t);e.CubicEase=o;var s=(function(e){function t(t,i){void 0===t&&(t=3),void 0===i&&(i=3);var r=e.call(this)||this;return r.oscillations=t,r.springiness=i,r}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.oscillations),i=Math.max(0,this.springiness);return(0==i?e:(Math.exp(i*e)-1)/(Math.exp(i)-1))*Math.sin((6.283185307179586*t+1.5707963267948966)*e)},t})(t);e.ElasticEase=s;var a=(function(e){function t(t){void 0===t&&(t=2);var i=e.call(this)||this;return i.exponent=t,i}return __extends(t,e),t.prototype.easeInCore=function(e){return this.exponent<=0?e:(Math.exp(this.exponent*e)-1)/(Math.exp(this.exponent)-1)},t})(t);e.ExponentialEase=a;var l=(function(e){function t(t){void 0===t&&(t=2);var i=e.call(this)||this;return i.power=t,i}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.power);return Math.pow(e,t)},t})(t);e.PowerEase=l;var h=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e},t})(t);e.QuadraticEase=h;var u=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e*e},t})(t);e.QuarticEase=u;var c=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e*e*e},t})(t);e.QuinticEase=c;var f=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return 1-Math.sin(1.5707963267948966*(1-e))},t})(t);e.SineEase=f;var d=(function(t){function i(e,i,r,n){void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=1),void 0===n&&(n=1);var o=t.call(this)||this;return o.x1=e,o.y1=i,o.x2=r,o.y2=n,o}return __extends(i,t),i.prototype.easeInCore=function(t){return e.BezierCurve.interpolate(t,this.x1,this.y1,this.x2,this.y2)},i})(t);e.BezierCurveEase=d})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e){this._actionManager=e}return e.prototype.isValid=function(){return!0},e.prototype._getProperty=function(e){return this._actionManager._getProperty(e)},e.prototype._getEffectiveTarget=function(e,t){return this._actionManager._getEffectiveTarget(e,t)},e.prototype.serialize=function(){},e.prototype._serialize=function(e){return{type:2,children:[],name:e.name,properties:e.properties}},e})();e.Condition=t;var i=(function(t){function i(e,r,n,o,s){void 0===s&&(s=i.IsEqual);var a=t.call(this,e)||this;return a.propertyPath=n,a.value=o,a.operator=s,a._target=r,a._effectiveTarget=a._getEffectiveTarget(r,a.propertyPath),a._property=a._getProperty(a.propertyPath),a}return __extends(i,t),Object.defineProperty(i,"IsEqual",{get:function(){return i._IsEqual},enumerable:!0,configurable:!0}),Object.defineProperty(i,"IsDifferent",{get:function(){return i._IsDifferent},enumerable:!0,configurable:!0}),Object.defineProperty(i,"IsGreater",{get:function(){return i._IsGreater},enumerable:!0,configurable:!0}),Object.defineProperty(i,"IsLesser",{get:function(){return i._IsLesser},enumerable:!0,configurable:!0}),i.prototype.isValid=function(){switch(this.operator){case i.IsGreater:return this._effectiveTarget[this._property]>this.value;case i.IsLesser:return this._effectiveTarget[this._property]-1&&this._scene._actionManagers.splice(e,1)},t.prototype.getScene=function(){return this._scene},t.prototype.hasSpecificTriggers=function(e){for(var t=0;t-1)return!0}return!1},t.prototype.hasSpecificTrigger=function(e){for(var t=0;t=t._OnPickTrigger&&i.trigger<=t._OnPointerOutTrigger)return!0}return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasPickTriggers",{get:function(){for(var e=0;e=t._OnPickTrigger&&i.trigger<=t._OnPickUpTrigger)return!0}return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t,"HasTriggers",{get:function(){for(var e in t.Triggers)if(t.Triggers.hasOwnProperty(e))return!0;return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t,"HasPickTriggers",{get:function(){for(var e in t.Triggers)if(t.Triggers.hasOwnProperty(e)){var i=parseInt(e);if(i>=t._OnPickTrigger&&i<=t._OnPickUpTrigger)return!0}return!1},enumerable:!0,configurable:!0}),t.HasSpecificTrigger=function(e){for(var i in t.Triggers)if(t.Triggers.hasOwnProperty(i)){var r=parseInt(i);if(r===e)return!0}return!1},t.prototype.registerAction=function(i){return i.trigger===t.OnEveryFrameTrigger&&this.getScene().actionManager!==this?(e.Tools.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"),null):(this.actions.push(i),t.Triggers[i.trigger]?t.Triggers[i.trigger]++:t.Triggers[i.trigger]=1,i._actionManager=this,i._prepare(),i)},t.prototype.processTrigger=function(e,i){for(var r=0;r0;if(2===i.type?f.push(o):f.push(r),_){for(var m=new Array,g=0;g0){var f=c.properties[0].value,d=null===c.properties[0].targetType?f:n.getMeshByName(f);d._meshId&&(d.mesh=n.getMeshByID(d._meshId)),u={trigger:t[c.name],parameter:d}}else u=t[c.name];for(var p=0;p>0;this._vertexData[o+10]=t.cellIndex-s*n,this._vertexData[o+11]=s,this._vertexData[o+12]=t.color.r,this._vertexData[o+13]=t.color.g,this._vertexData[o+14]=t.color.b,this._vertexData[o+15]=t.color.a},t.prototype.intersects=function(t,i,r,n){for(var o=Math.min(this._capacity,this.sprites.length),s=e.Vector3.Zero(),a=e.Vector3.Zero(),l=Number.MAX_VALUE,h=null,u=e.Vector3.Zero(),c=i.getViewMatrix(),f=0;fp&&(l=p,h=d,n))break}}}if(h){var _=new e.PickingInfo;return _.hit=!0,_.pickedSprite=h,_.distance=l,_}return null},t.prototype.render=function(){if(this._effectBase.isReady()&&this._effectFog.isReady()&&this._spriteTexture&&this._spriteTexture.isReady()){for(var t=this._scene.getEngine(),i=this._spriteTexture.getBaseSize(),r=t.getDeltaTime(),n=Math.min(this._capacity,this.sprites.length),o=i.width/this.cellWidth,s=0,a=0;athis._delay&&(this._time=this._time%this._delay,this.cellIndex+=this._direction,this.cellIndex>this._toIndex&&(this._loopAnimation?this.cellIndex=this._fromIndex:(this.cellIndex=this._toIndex,this._animationStarted=!1,this._onAnimationEnd&&this._onAnimationEnd(),this.disposeWhenFinishedAnimating&&this.dispose()))))},t.prototype.dispose=function(){for(var e=0;et.x)return!1}else if(i=1/this.direction.x,r=(e.x-this.origin.x)*i,n=(t.x-this.origin.x)*i,n===-1/0&&(n=1/0),r>n&&(o=r,r=n,n=o),s=Math.max(r,s),a=Math.min(n,a),s>a)return!1;if(Math.abs(this.direction.y)<1e-7){if(this.origin.yt.y)return!1}else if(i=1/this.direction.y,r=(e.y-this.origin.y)*i,n=(t.y-this.origin.y)*i,n===-1/0&&(n=1/0),r>n&&(o=r,r=n,n=o),s=Math.max(r,s),a=Math.min(n,a),s>a)return!1;if(Math.abs(this.direction.z)<1e-7){if(this.origin.zt.z)return!1}else if(i=1/this.direction.z,r=(e.z-this.origin.z)*i,n=(t.z-this.origin.z)*i,n===-1/0&&(n=1/0),r>n&&(o=r,r=n,n=o),s=Math.max(r,s),a=Math.min(n,a),s>a)return!1;return!0},t.prototype.intersectsBox=function(e){return this.intersectsBoxMinMax(e.minimum,e.maximum)},t.prototype.intersectsSphere=function(e){var t=e.center.x-this.origin.x,i=e.center.y-this.origin.y,r=e.center.z-this.origin.z,n=t*t+i*i+r*r,o=e.radius*e.radius;if(n<=o)return!0;var s=t*this.direction.x+i*this.direction.y+r*this.direction.z;return!(s<0)&&n-s*s<=o},t.prototype.intersectsTriangle=function(t,i,r){this._edge1||(this._edge1=e.Vector3.Zero(),this._edge2=e.Vector3.Zero(),this._pvec=e.Vector3.Zero(),this._tvec=e.Vector3.Zero(),this._qvec=e.Vector3.Zero()),i.subtractToRef(t,this._edge1),r.subtractToRef(t,this._edge2),e.Vector3.CrossToRef(this.direction,this._edge2,this._pvec);var n=e.Vector3.Dot(this._edge1,this._pvec);if(0===n)return null;var o=1/n;this.origin.subtractToRef(t,this._tvec);var s=e.Vector3.Dot(this._tvec,this._pvec)*o;if(s<0||s>1)return null;e.Vector3.CrossToRef(this._tvec,this._edge1,this._qvec);var a=e.Vector3.Dot(this.direction,this._qvec)*o;if(a<0||s+a>1)return null;var l=e.Vector3.Dot(this._edge2,this._qvec)*o;return l>this.length?null:new e.IntersectionInfo(s,a,l)},t.prototype.intersectsPlane=function(t){var i,r=e.Vector3.Dot(t.normal,this.direction);if(Math.abs(r)<9.99999997475243e-7)return null;var n=e.Vector3.Dot(t.normal,this.origin);return i=(-t.d-n)/r,i<0?i<-9.99999997475243e-7?null:0:i},t.prototype.intersectsMesh=function(i,r){var n=e.Tmp.Matrix[0];return i.getWorldMatrix().invertToRef(n),this._tmpRay?t.TransformToRef(this,n,this._tmpRay):this._tmpRay=t.Transform(this,n),i.intersects(this._tmpRay,r)},t.prototype.intersectsMeshes=function(e,t,i){i?i.length=0:i=[];for(var r=0;rt.distance?1:0},t.prototype.intersectionSegment=function(i,r,n){var o,s,a,l,h=this.origin.add(this.direction.multiplyByFloats(t.rayl,t.rayl,t.rayl)),u=r.subtract(i),c=h.subtract(this.origin),f=i.subtract(this.origin),d=e.Vector3.Dot(u,u),p=e.Vector3.Dot(u,c),_=e.Vector3.Dot(c,c),m=e.Vector3.Dot(u,f),g=e.Vector3.Dot(c,f),v=d*_-p*p,y=v,b=v;vy&&(s=y,l=g+p,b=_)),l<0?(l=0,-m<0?s=0:-m>d?s=y:(s=-m,y=d)):l>b&&(l=b,-m+p<0?s=0:-m+p>d?s=y:(s=-m+p,y=d)),o=Math.abs(s)0&&a<=this.length&&T.lengthSquared()i.x+r)&&(!(i.x-r>t.x)&&(!(e.y>i.y+r)&&(!(i.y-r>t.y)&&(!(e.z>i.z+r)&&!(i.z-r>t.z)))))},i=(function(){var e={root:0,found:!1};return function(t,i,r,n){e.root=0,e.found=!1;var o=i*i-4*t*r;if(o<0)return e;var s=Math.sqrt(o),a=(-i-s)/(2*t),l=(-i+s)/(2*t);if(a>l){var h=l;l=a,a=h}return a>0&&a0&&l=0))},r.prototype._canDoCollision=function(i,r,n,o){var s=e.Vector3.Distance(this.basePointWorld,i),a=Math.max(this.radius.x,this.radius.y,this.radius.z);return!(s>this.velocityWorldLength+a+r)&&!!t(n,o,this.basePointWorld,this.velocityWorldLength+a)},r.prototype._testTriangle=function(t,r,n,o,s,a){var l,h=!1;r||(r=[]),r[t]||(r[t]=new e.Plane(0,0,0,0),r[t].copyFromPoints(n,o,s));var u=r[t];if(a||u.isFrontFacingTo(this.normalizedVelocity,0)){var c=u.signedDistanceTo(this.basePoint),f=e.Vector3.Dot(u.normal,this.velocity);if(0==f){ if(Math.abs(c)>=1)return;h=!0,l=0}else{l=(-1-c)/f;var d=(1-c)/f;if(l>d){var p=d;d=l,l=p}if(l>1||d<0)return;l<0&&(l=0),l>1&&(l=1)}this._collisionPoint.copyFromFloats(0,0,0);var _=!1,m=1;if(h||(this.basePoint.subtractToRef(u.normal,this._planeIntersectionPoint),this.velocity.scaleToRef(l,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,n,o,s,u.normal)&&(_=!0,m=l,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!_){var g=this.velocity.lengthSquared(),v=g;this.basePoint.subtractToRef(n,this._tempVector);var y=2*e.Vector3.Dot(this.velocity,this._tempVector),b=this._tempVector.lengthSquared()-1,x=i(v,y,b,m);x.found&&(m=x.root,_=!0,this._collisionPoint.copyFrom(n)),this.basePoint.subtractToRef(o,this._tempVector),y=2*e.Vector3.Dot(this.velocity,this._tempVector),b=this._tempVector.lengthSquared()-1,x=i(v,y,b,m),x.found&&(m=x.root,_=!0,this._collisionPoint.copyFrom(o)),this.basePoint.subtractToRef(s,this._tempVector),y=2*e.Vector3.Dot(this.velocity,this._tempVector),b=this._tempVector.lengthSquared()-1,x=i(v,y,b,m),x.found&&(m=x.root,_=!0,this._collisionPoint.copyFrom(s)),o.subtractToRef(n,this._edge),n.subtractToRef(this.basePoint,this._baseToVertex);var T=this._edge.lengthSquared(),A=e.Vector3.Dot(this._edge,this.velocity),E=e.Vector3.Dot(this._edge,this._baseToVertex);if(v=T*-g+A*A,y=T*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*A*E,b=T*(1-this._baseToVertex.lengthSquared())+E*E,x=i(v,y,b,m),x.found){var P=(A*x.root-E)/T;P>=0&&P<=1&&(m=x.root,_=!0,this._edge.scaleInPlace(P),n.addToRef(this._edge,this._collisionPoint))}s.subtractToRef(o,this._edge),o.subtractToRef(this.basePoint,this._baseToVertex),T=this._edge.lengthSquared(),A=e.Vector3.Dot(this._edge,this.velocity),E=e.Vector3.Dot(this._edge,this._baseToVertex),v=T*-g+A*A,y=T*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*A*E,b=T*(1-this._baseToVertex.lengthSquared())+E*E,x=i(v,y,b,m),x.found&&(P=(A*x.root-E)/T)>=0&&P<=1&&(m=x.root,_=!0,this._edge.scaleInPlace(P),o.addToRef(this._edge,this._collisionPoint)),n.subtractToRef(s,this._edge),s.subtractToRef(this.basePoint,this._baseToVertex),T=this._edge.lengthSquared(),A=e.Vector3.Dot(this._edge,this.velocity),E=e.Vector3.Dot(this._edge,this._baseToVertex),v=T*-g+A*A,y=T*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*A*E,b=T*(1-this._baseToVertex.lengthSquared())+E*E,x=i(v,y,b,m),x.found&&(P=(A*x.root-E)/T)>=0&&P<=1&&(m=x.root,_=!0,this._edge.scaleInPlace(P),s.addToRef(this._edge,this._collisionPoint))}if(_){var M=m*this.velocity.length();(!this.collisionFound||M4)){++n._runningUpdated;var e={updatedMeshes:n._addUpdateMeshesList,updatedGeometries:n._addUpdateGeometriesList,removedGeometries:n._toRemoveGeometryArray,removedMeshes:n._toRemoveMeshesArray},i={payload:e,taskType:t.UPDATE},r=[];for(var o in e.updatedGeometries)e.updatedGeometries.hasOwnProperty(o)&&(r.push(i.payload.updatedGeometries[o].indices.buffer),r.push(i.payload.updatedGeometries[o].normals.buffer),r.push(i.payload.updatedGeometries[o].positions.buffer));n._worker.postMessage(i,r),n._addUpdateMeshesList={},n._addUpdateGeometriesList={},n._toRemoveGeometryArray=[],n._toRemoveMeshesArray=[]}},this._onMessageFromWorker=function(r){var o=r.data;if(o.error!=i.SUCCESS)return void e.Tools.Warn("error returned from worker!");switch(o.taskType){case t.INIT:n._init=!0,n._scene.meshes.forEach((function(e){n.onMeshAdded(e)})),n._scene.getGeometries().forEach((function(e){n.onGeometryAdded(e)}));break;case t.UPDATE:n._runningUpdated--;break;case t.COLLIDE:n._runningCollisionTask=!1;var s=o.payload;if(!n._collisionsCallbackArray[s.collisionId])return;var a=n._collisionsCallbackArray[s.collisionId];if(a){var l=n._scene.getMeshByUniqueID(s.collidedMeshUniqueId);l&&a(s.collisionId,e.Vector3.FromArray(s.newPosition),l)}n._collisionsCallbackArray[s.collisionId]=null}},this._collisionsCallbackArray=[],this._init=!1,this._runningUpdated=0,this._runningCollisionTask=!1,this._addUpdateMeshesList={},this._addUpdateGeometriesList={},this._toRemoveGeometryArray=[],this._toRemoveMeshesArray=[]}return r.prototype.getNewPosition=function(e,i,r,n,o,s,a){if(this._init&&!this._collisionsCallbackArray[a]&&!this._collisionsCallbackArray[a+1e5]){e.divideToRef(r.radius,this._scaledPosition),i.divideToRef(r.radius,this._scaledVelocity),this._collisionsCallbackArray[a]=s;var l={collider:{position:this._scaledPosition.asArray(),velocity:this._scaledVelocity.asArray(),radius:r.radius.asArray()},collisionId:a,excludedMeshUniqueId:o?o.uniqueId:null,maximumRetry:n},h={payload:l,taskType:t.COLLIDE};this._worker.postMessage(h)}},r.prototype.init=function(i){this._scene=i,this._scene.registerAfterRender(this._afterRender);var r=e.WorkerIncluded?e.Engine.CodeRepository+"Collisions/babylon.collisionWorker.js":URL.createObjectURL(new Blob([e.CollisionWorker],{type:"application/javascript"}));this._worker=new Worker(r),this._worker.onmessage=this._onMessageFromWorker;var n={payload:{},taskType:t.INIT};this._worker.postMessage(n)},r.prototype.destroy=function(){this._scene.unregisterAfterRender(this._afterRender),this._worker.terminate()},r.prototype.onMeshAdded=function(e){e.registerAfterWorldMatrixUpdate(this.onMeshUpdated),this.onMeshUpdated(e)},r.prototype.onMeshRemoved=function(e){this._toRemoveMeshesArray.push(e.uniqueId)},r.prototype.onGeometryAdded=function(e){e.onGeometryUpdated=this.onGeometryUpdated,this.onGeometryUpdated(e)},r.prototype.onGeometryDeleted=function(e){this._toRemoveGeometryArray.push(e.id)},r.SerializeMesh=function(t){var i=[];t.subMeshes&&(i=t.subMeshes.map((function(e,t){var i=e.getBoundingInfo();return{position:t,verticesStart:e.verticesStart,verticesCount:e.verticesCount,indexStart:e.indexStart,indexCount:e.indexCount,hasMaterial:!!e.getMaterial(),sphereCenter:i.boundingSphere.centerWorld.asArray(),sphereRadius:i.boundingSphere.radiusWorld,boxMinimum:i.boundingBox.minimumWorld.asArray(),boxMaximum:i.boundingBox.maximumWorld.asArray()}})));var r=null;if(t instanceof e.Mesh){var n=t.geometry;r=n?n.id:null}else if(t instanceof e.InstancedMesh){var n=t.sourceMesh.geometry;r=n?n.id:null}var o=t.getBoundingInfo();return{uniqueId:t.uniqueId,id:t.id,name:t.name,geometryId:r,sphereCenter:o.boundingSphere.centerWorld.asArray(),sphereRadius:o.boundingSphere.radiusWorld,boxMinimum:o.boundingBox.minimumWorld.asArray(),boxMaximum:o.boundingBox.maximumWorld.asArray(),worldMatrixFromCache:t.worldMatrixFromCache.asArray(),subMeshes:i,checkCollisions:t.checkCollisions}},r.SerializeGeometry=function(t){return{id:t.id,positions:new Float32Array(t.getVerticesData(e.VertexBuffer.PositionKind)||[]),normals:new Float32Array(t.getVerticesData(e.VertexBuffer.NormalKind)||[]),indices:new Uint32Array(t.getIndices()||[])}},r})();e.CollisionCoordinatorWorker=r;var n=(function(){function t(){this._scaledPosition=e.Vector3.Zero(),this._scaledVelocity=e.Vector3.Zero(),this._finalPosition=e.Vector3.Zero()}return t.prototype.getNewPosition=function(e,t,i,r,n,o,s){e.divideToRef(i.radius,this._scaledPosition),t.divideToRef(i.radius,this._scaledVelocity),i.collidedMesh=null,i.retry=0,i.initialVelocity=this._scaledVelocity,i.initialPosition=this._scaledPosition,this._collideWithWorld(this._scaledPosition,this._scaledVelocity,i,r,this._finalPosition,n),this._finalPosition.multiplyInPlace(i.radius),o(s,this._finalPosition,i.collidedMesh)},t.prototype.init=function(e){this._scene=e},t.prototype.destroy=function(){},t.prototype.onMeshAdded=function(e){},t.prototype.onMeshUpdated=function(e){},t.prototype.onMeshRemoved=function(e){},t.prototype.onGeometryAdded=function(e){},t.prototype.onGeometryUpdated=function(e){},t.prototype.onGeometryDeleted=function(e){},t.prototype._collideWithWorld=function(t,i,r,n,o,s){void 0===s&&(s=null);var a=10*e.Engine.CollisionsEpsilon;if(r.retry>=n)return void o.copyFrom(t);var l=s?s.collisionMask:r.collisionMask;r._initialize(t,i,a);for(var h=0;h=t*e&&(this._currentFrameCounter=0,++this.cellIndex>this.particleSystem.endSpriteCellID&&(this.cellIndex=this.particleSystem.endSpriteCellID))},t.prototype.updateCellIndexWithCustomSpeed=function(){this._currentFrameCounter>=this.particleSystem.spriteCellChangeSpeed?(this.cellIndex++,this._currentFrameCounter=0,this.cellIndex>this.particleSystem.endSpriteCellID&&(this.particleSystem.spriteCellLoop?this.cellIndex=this.particleSystem.startSpriteCellID:this.cellIndex=this.particleSystem.endSpriteCellID)):this._currentFrameCounter++},t.prototype.copyTo=function(e){e.position.copyFrom(this.position),e.direction.copyFrom(this.direction),e.color.copyFrom(this.color),e.colorStep.copyFrom(this.colorStep),e.lifeTime=this.lifeTime,e.age=this.age,e.size=this.size,e.angle=this.angle,e.angularSpeed=this.angularSpeed,e.particleSystem=this.particleSystem,e.cellIndex=this.cellIndex},t})();e.Particle=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=function(e,t){return e===t?e:Math.random()*(t-e)+e},i=(function(){function i(r,n,o,s,a,l){void 0===s&&(s=null),void 0===a&&(a=!1),void 0===l&&(l=.01);var h=this;this.name=r,this._isAnimationSheetEnabled=a,this.animations=[],this.renderingGroupId=0,this.emitter=null,this.emitRate=10,this.manualEmitCount=-1,this.updateSpeed=.01,this.targetStopDuration=0,this.disposeOnStop=!1,this.minEmitPower=1,this.maxEmitPower=1,this.minLifeTime=1,this.maxLifeTime=1,this.minSize=1,this.maxSize=1,this.minAngularSpeed=0,this.maxAngularSpeed=0,this.layerMask=268435455,this.customShader=null,this.preventAutoStart=!1,this.onDisposeObservable=new e.Observable,this.onAnimationEnd=null,this.blendMode=i.BLENDMODE_ONEONE,this.forceDepthWrite=!1,this.gravity=e.Vector3.Zero(),this.direction1=new e.Vector3(0,1,0),this.direction2=new e.Vector3(0,1,0),this.minEmitBox=new e.Vector3(-.5,-.5,-.5),this.maxEmitBox=new e.Vector3(.5,.5,.5),this.color1=new e.Color4(1,1,1,1),this.color2=new e.Color4(1,1,1,1),this.colorDead=new e.Color4(0,0,0,1),this.textureMask=new e.Color4(1,1,1,1),this.particles=new Array,this._stockParticles=new Array,this._newPartsExcess=0,this._vertexBuffers={},this._scaledColorStep=new e.Color4(0,0,0,0),this._colorDiff=new e.Color4(0,0,0,0),this._scaledDirection=e.Vector3.Zero(),this._scaledGravity=e.Vector3.Zero(),this._currentRenderId=-1,this._started=!1,this._stopped=!1,this._actualFrame=0,this.startSpriteCellID=0,this.endSpriteCellID=0,this.spriteCellLoop=!0,this.spriteCellChangeSpeed=0,this.spriteCellWidth=0,this.spriteCellHeight=0,this._vertexBufferSize=11,this.appendParticleVertexes=null,this.id=r,this._capacity=n,this._epsilon=l,a&&(this._vertexBufferSize=12),this._scene=o||e.Engine.LastCreatedScene,this._customEffect=s,o.particleSystems.push(this),this._createIndexBuffer(),this._vertexData=new Float32Array(n*this._vertexBufferSize*4),this._vertexBuffer=new e.Buffer(o.getEngine(),this._vertexData,!0,this._vertexBufferSize);var u=this._vertexBuffer.createVertexBuffer(e.VertexBuffer.PositionKind,0,3),c=this._vertexBuffer.createVertexBuffer(e.VertexBuffer.ColorKind,3,4),f=this._vertexBuffer.createVertexBuffer("options",7,4);if(this._isAnimationSheetEnabled){var d=this._vertexBuffer.createVertexBuffer("cellIndex",11,1);this._vertexBuffers.cellIndex=d}this._vertexBuffers[e.VertexBuffer.PositionKind]=u,this._vertexBuffers[e.VertexBuffer.ColorKind]=c,this._vertexBuffers.options=f,this.startDirectionFunction=function(i,r,n,o){var s=t(h.direction1.x,h.direction2.x),a=t(h.direction1.y,h.direction2.y),l=t(h.direction1.z,h.direction2.z);e.Vector3.TransformNormalFromFloatsToRef(s*i,a*i,l*i,r,n)},this.startPositionFunction=function(i,r,n){var o=t(h.minEmitBox.x,h.maxEmitBox.x),s=t(h.minEmitBox.y,h.maxEmitBox.y),a=t(h.minEmitBox.z,h.maxEmitBox.z);e.Vector3.TransformCoordinatesFromFloatsToRef(o,s,a,i,r)},this.updateFunction=function(e){for(var t=0;t=i.lifeTime?(h.recycleParticle(i),t--):(i.colorStep.scaleToRef(h._scaledUpdateSpeed,h._scaledColorStep),i.color.addInPlace(h._scaledColorStep),i.color.a<0&&(i.color.a=0),i.angle+=i.angularSpeed*h._scaledUpdateSpeed,i.direction.scaleToRef(h._scaledUpdateSpeed,h._scaledDirection),i.position.addInPlace(h._scaledDirection),h.gravity.scaleToRef(h._scaledUpdateSpeed,h._scaledGravity),i.direction.addInPlace(h._scaledGravity),h._isAnimationSheetEnabled&&i.updateCellIndex(h._scaledUpdateSpeed))}}}return Object.defineProperty(i.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isAnimationSheetEnabled",{get:function(){return this._isAnimationSheetEnabled},enumerable:!0,configurable:!0}),i.prototype._createIndexBuffer=function(){for(var e=[],t=0,i=0;i0,this.updateFunction(this.particles);var r;if(this.emitter.position){r=this.emitter.getWorldMatrix()}else{var n=this.emitter;r=e.Matrix.Translation(n.x,n.y,n.z)}for(var o,s=0;s-1?(t=this.manualEmitCount,this._newPartsExcess=0,this.manualEmitCount=0):(t=this.emitRate*this._scaledUpdateSpeed>>0,this._newPartsExcess+=this.emitRate*this._scaledUpdateSpeed-t),this._newPartsExcess>1&&(t+=this._newPartsExcess>>0,this._newPartsExcess-=this._newPartsExcess>>0),this._alive=!1,this._stopped?t=0:(this._actualFrame+=this._scaledUpdateSpeed,this.targetStopDuration&&this._actualFrame>=this.targetStopDuration&&this.stop()),this._update(t),this._stopped&&(this._alive||(this._started=!1,this.onAnimationEnd&&this.onAnimationEnd(),this.disposeOnStop&&this._scene._toBeDisposed.push(this))),this._isAnimationSheetEnabled?this.appendParticleVertexes=this.appenedParticleVertexesWithSheet:this.appendParticleVertexes=this.appenedParticleVertexesNoSheet;for(var i=0,r=0;r-1&&this._scene.particleSystems.splice(e,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},i.prototype.clone=function(t,r){var n=null,o=null;if(null!=this.customShader){o=this.customShader;var s=o.shaderOptions.defines.length>0?o.shaderOptions.defines.join("\n"):"";n=this._scene.getEngine().createEffectForParticles(o.shaderPath.fragmentElement,o.shaderOptions.uniforms,o.shaderOptions.samplers,s)}var a=new i(t,this._capacity,this._scene,n);return a.customShader=o,e.Tools.DeepCopy(this,a,["particles","customShader"]),void 0===r&&(r=this.emitter),a.emitter=r,this.particleTexture&&(a.particleTexture=new e.Texture(this.particleTexture.url,this._scene)),this.preventAutoStart||a.start(),a},i.prototype.serialize=function(){var t={};if(t.name=this.name,t.id=this.id,this.emitter.position){var i=this.emitter;t.emitterId=i.id}else{var r=this.emitter;t.emitter=r.asArray()}return t.capacity=this.getCapacity(),this.particleTexture&&(t.textureName=this.particleTexture.name),e.Animation.AppendSerializedAnimations(this,t),t.minAngularSpeed=this.minAngularSpeed,t.maxAngularSpeed=this.maxAngularSpeed,t.minSize=this.minSize,t.maxSize=this.maxSize,t.minEmitPower=this.minEmitPower,t.maxEmitPower=this.maxEmitPower,t.minLifeTime=this.minLifeTime,t.maxLifeTime=this.maxLifeTime,t.emitRate=this.emitRate,t.minEmitBox=this.minEmitBox.asArray(),t.maxEmitBox=this.maxEmitBox.asArray(),t.gravity=this.gravity.asArray(),t.direction1=this.direction1.asArray(),t.direction2=this.direction2.asArray(),t.color1=this.color1.asArray(),t.color2=this.color2.asArray(),t.colorDead=this.colorDead.asArray(),t.updateSpeed=this.updateSpeed,t.targetStopDuration=this.targetStopDuration,t.textureMask=this.textureMask.asArray(),t.blendMode=this.blendMode,t.customShader=this.customShader,t.preventAutoStart=this.preventAutoStart,t},i.Parse=function(t,r,n){var o=t.name,s=null,a=null;if(t.customShader){a=t.customShader;var l=a.shaderOptions.defines.length>0?a.shaderOptions.defines.join("\n"):"";s=r.getEngine().createEffectForParticles(a.shaderPath.fragmentElement,a.shaderOptions.uniforms,a.shaderOptions.samplers,l)}var h=new i(o,t.capacity,r,s);if(h.customShader=a,t.id&&(h.id=t.id),t.preventAutoStart&&(h.preventAutoStart=t.preventAutoStart),t.textureName&&(h.particleTexture=new e.Texture(n+t.textureName,r),h.particleTexture.name=t.textureName),t.emitterId?h.emitter=r.getLastMeshByID(t.emitterId):h.emitter=e.Vector3.FromArray(t.emitter),t.animations)for(var u=0;u-1&&this._scene.particleSystems.splice(e,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},t.prototype.clone=function(e,t){return null},t.prototype.serialize=function(){},t})();e.GPUParticleSystem=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r,n,o,s,a,l){void 0===l&&(l=null),this.idx=0,this.color=new e.Color4(1,1,1,1),this.position=e.Vector3.Zero(),this.rotation=e.Vector3.Zero(),this.scaling=e.Vector3.One(),this.uvs=new e.Vector4(0,0,1,1),this.velocity=e.Vector3.Zero(),this.pivot=e.Vector3.Zero(),this.alive=!0,this.isVisible=!0,this._pos=0,this._ind=0,this.shapeId=0,this.idxInShape=0,this._stillInvisible=!1,this.idx=t,this._pos=i,this._ind=r,this._model=n,this.shapeId=o,this.idxInShape=s,this._sps=a,l&&(this._modelBoundingInfo=l,this._boundingInfo=new e.BoundingInfo(l.minimum,l.maximum))}return Object.defineProperty(t.prototype,"scale",{get:function(){return this.scaling},set:function(e){this.scaling=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"quaternion",{get:function(){return this.rotationQuaternion},set:function(e){this.rotationQuaternion=e},enumerable:!0,configurable:!0}),t.prototype.intersectsMesh=function(t){return!(!this._boundingInfo||!t._boundingInfo)&&(this._sps._bSphereOnly?e.BoundingSphere.Intersects(this._boundingInfo.boundingSphere,t._boundingInfo.boundingSphere):this._boundingInfo.intersects(t._boundingInfo,!1))},t})();e.SolidParticle=t;var i=(function(){function e(e,t,i,r,n,o){this._indicesLength=0,this.shapeID=e,this._shape=t,this._indicesLength=i,this._shapeUV=r,this._positionFunction=n,this._vertexFunction=o}return e})();e.ModelShape=i;var r=(function(){function e(){this.ind=0,this.indicesLength=0,this.sqDistance=0}return e})();e.DepthSortedParticle=r})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r){this.particles=new Array,this.nbParticles=0,this.billboard=!1,this.recomputeNormals=!0,this.counter=0,this.vars={},this._positions=new Array,this._indices=new Array,this._normals=new Array,this._colors=new Array,this._uvs=new Array,this._index=0,this._updatable=!0,this._pickable=!1,this._isVisibilityBoxLocked=!1,this._alwaysVisible=!1,this._depthSort=!1,this._shapeCounter=0,this._copy=new e.SolidParticle(0,0,0,null,0,0,this), this._color=new e.Color4(0,0,0,0),this._computeParticleColor=!0,this._computeParticleTexture=!0,this._computeParticleRotation=!0,this._computeParticleVertex=!1,this._computeBoundingBox=!1,this._depthSortParticles=!0,this._cam_axisZ=e.Vector3.Zero(),this._cam_axisY=e.Vector3.Zero(),this._cam_axisX=e.Vector3.Zero(),this._axisZ=e.Axis.Z,this._camDir=e.Vector3.Zero(),this._camInvertedPosition=e.Vector3.Zero(),this._rotMatrix=new e.Matrix,this._invertMatrix=new e.Matrix,this._rotated=e.Vector3.Zero(),this._quaternion=new e.Quaternion,this._vertex=e.Vector3.Zero(),this._normal=e.Vector3.Zero(),this._yaw=0,this._pitch=0,this._roll=0,this._halfroll=0,this._halfpitch=0,this._halfyaw=0,this._sinRoll=0,this._cosRoll=0,this._sinPitch=0,this._cosPitch=0,this._sinYaw=0,this._cosYaw=0,this._mustUnrotateFixedNormals=!1,this._minimum=e.Tmp.Vector3[0],this._maximum=e.Tmp.Vector3[1],this._minBbox=e.Tmp.Vector3[4],this._maxBbox=e.Tmp.Vector3[5],this._particlesIntersect=!1,this._depthSortFunction=function(e,t){return t.sqDistance-e.sqDistance},this._needs32Bits=!1,this._bSphereOnly=!1,this._bSphereRadiusFactor=1,this.name=t,this._scene=i||e.Engine.LastCreatedScene,this._camera=i.activeCamera,this._pickable=!!r&&r.isPickable,this._depthSort=!!r&&r.enableDepthSort,this._particlesIntersect=!!r&&r.particleIntersection,this._bSphereOnly=!!r&&r.boundingSphereOnly,this._bSphereRadiusFactor=r&&r.bSphereRadiusFactor?r.bSphereRadiusFactor:1,r&&r.updatable?this._updatable=r.updatable:this._updatable=!0,this._pickable&&(this.pickedParticles=[]),this._depthSort&&(this.depthSortedParticles=[])}return t.prototype.buildMesh=function(){if(0===this.nbParticles){var t=e.MeshBuilder.CreateDisc("",{radius:1,tessellation:3},this._scene);this.addShape(t,1),t.dispose()}this._indices32=this._needs32Bits?new Uint32Array(this._indices):new Uint16Array(this._indices),this._positions32=new Float32Array(this._positions),this._uvs32=new Float32Array(this._uvs),this._colors32=new Float32Array(this._colors),this.recomputeNormals&&e.VertexData.ComputeNormals(this._positions32,this._indices,this._normals),this._normals32=new Float32Array(this._normals),this._fixedNormal32=new Float32Array(this._normals),this._mustUnrotateFixedNormals&&this._unrotateFixedNormals();var i=new e.VertexData;i.indices=this._depthSort?this._indices:this._indices32,i.set(this._positions32,e.VertexBuffer.PositionKind),i.set(this._normals32,e.VertexBuffer.NormalKind),this._uvs32&&i.set(this._uvs32,e.VertexBuffer.UVKind),this._colors32&&i.set(this._colors32,e.VertexBuffer.ColorKind);var r=new e.Mesh(this.name,this._scene);return i.applyToMesh(r,this._updatable),this.mesh=r,this.mesh.isPickable=this._pickable,this._depthSort||(this._indices=null),this._positions=null,this._normals=null,this._uvs=null,this._colors=null,this._updatable||(this.particles.length=0),r},t.prototype.digest=function(t,i){var r=i&&i.facetNb||1,n=i&&i.number||0,o=i&&i.delta||0,s=t.getVerticesData(e.VertexBuffer.PositionKind),a=t.getIndices(),l=t.getVerticesData(e.VertexBuffer.UVKind),h=t.getVerticesData(e.VertexBuffer.ColorKind),u=t.getVerticesData(e.VertexBuffer.NormalKind),c=0,f=a.length/3;n?(n=n>f?f:n,r=Math.round(f/n),o=0):r=r>f?f:r;for(var d=[],p=[],_=[],m=[],g=e.Tmp.Vector3[0],v=r;cf-r&&(r=f-c),d.length=0,p.length=0,_.length=0,m.length=0;for(var y=0,b=3*c;b<3*(c+r);b++){p.push(y);var x=a[b];d.push(s[3*x],s[3*x+1],s[3*x+2]),l&&_.push(l[2*x],l[2*x+1]),h&&m.push(h[4*x],h[4*x+1],h[4*x+2],h[4*x+3]),y++}var T,A=this.nbParticles,E=this._posToShape(d),P=this._uvsToShapeUV(_);for(T=0;T65535&&(this._needs32Bits=!0)}if(this._pickable){var b=n.length/3;for(_=0;_=this.nbParticles?this.nbParticles-1:i,this._computeBoundingBox&&(0==t&&i==this.nbParticles-1?(e.Vector3.FromFloatsToRef(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,this._minimum),e.Vector3.FromFloatsToRef(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,this._maximum)):this.mesh._boundingInfo&&(this._minimum.copyFrom(this.mesh._boundingInfo.boundingBox.minimum),this._maximum.copyFrom(this.mesh._boundingInfo.boundingBox.maximum))),s=this.particles[t]._pos;var f=s/3|0;l=4*f,u=2*f;for(var d=t;d<=i;d++){if(this._particle=this.particles[d],this._shape=this._particle._model._shape,this._shapeUV=this._particle._model._shapeUV,this.updateParticle(this._particle),this._depthSort&&this._depthSortParticles){var p=this.depthSortedParticles[d];p.ind=this._particle._ind,p.indicesLength=this._particle._model._indicesLength,p.sqDistance=e.Vector3.DistanceSquared(this._particle.position,this._camInvertedPosition)}if(!this._particle.alive||this._particle._stillInvisible&&!this._particle.isVisible)c=this._shape.length,s+=3*c,l+=4*c,u+=2*c;else{if(this._particle.isVisible)for(this._particle._stillInvisible=!1,this.billboard&&(this._particle.rotation.x=0,this._particle.rotation.y=0),(this._computeParticleRotation||this.billboard)&&(this._particle.rotationQuaternion?this._quaternion.copyFrom(this._particle.rotationQuaternion):(this._yaw=this._particle.rotation.y,this._pitch=this._particle.rotation.x,this._roll=this._particle.rotation.z,this._quaternionRotationYPR()),this._quaternionToRotationMatrix()),c=0;cthis._maximum.x&&(this._maximum.x=this._positions32[o]),this._positions32[o+1]this._maximum.y&&(this._maximum.y=this._positions32[o+1]),this._positions32[o+2]this._maximum.z&&(this._maximum.z=this._positions32[o+2])),this._computeParticleVertex||(this._normal.x=this._fixedNormal32[o],this._normal.y=this._fixedNormal32[o+1],this._normal.z=this._fixedNormal32[o+2],this._rotated.x=this._normal.x*this._rotMatrix.m[0]+this._normal.y*this._rotMatrix.m[4]+this._normal.z*this._rotMatrix.m[8],this._rotated.y=this._normal.x*this._rotMatrix.m[1]+this._normal.y*this._rotMatrix.m[5]+this._normal.z*this._rotMatrix.m[9],this._rotated.z=this._normal.x*this._rotMatrix.m[2]+this._normal.y*this._rotMatrix.m[6]+this._normal.z*this._rotMatrix.m[10],this._normals32[o]=this._cam_axisX.x*this._rotated.x+this._cam_axisY.x*this._rotated.y+this._cam_axisZ.x*this._rotated.z,this._normals32[o+1]=this._cam_axisX.y*this._rotated.x+this._cam_axisY.y*this._rotated.y+this._cam_axisZ.y*this._rotated.z,this._normals32[o+2]=this._cam_axisX.z*this._rotated.x+this._cam_axisY.z*this._rotated.y+this._cam_axisZ.z*this._rotated.z),this._computeParticleColor&&this._particle.color&&(this._colors32[a]=this._particle.color.r,this._colors32[a+1]=this._particle.color.g,this._colors32[a+2]=this._particle.color.b,this._colors32[a+3]=this._particle.color.a),this._computeParticleTexture&&(this._uvs32[h]=this._shapeUV[2*c]*(this._particle.uvs.z-this._particle.uvs.x)+this._particle.uvs.x,this._uvs32[h+1]=this._shapeUV[2*c+1]*(this._particle.uvs.w-this._particle.uvs.y)+this._particle.uvs.y);else for(this._particle._stillInvisible=!0,c=0;cthis._maxX||ithis._maxZ)return this.position.y;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var s=this._getFacetAt(t,i),a=-(s.x*t+s.z*i+s.w)/s.y;return e.Vector3.TransformCoordinatesFromFloatsToRef(0,a,0,r,o),o.y},i.prototype.getNormalAtCoordinates=function(t,i){var r=new e.Vector3(0,1,0);return this.getNormalAtCoordinatesToRef(t,i,r),r},i.prototype.getNormalAtCoordinatesToRef=function(t,i,r){var n=this.getWorldMatrix(),o=e.Tmp.Matrix[5];n.invertToRef(o);var s=e.Tmp.Vector3[8];if(e.Vector3.TransformCoordinatesFromFloatsToRef(t,0,i,o,s),t=s.x,i=s.z,tthis._maxX||ithis._maxZ)return this;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var a=this._getFacetAt(t,i);return e.Vector3.TransformNormalFromFloatsToRef(a.x,a.y,a.z,n,r),this},i.prototype.updateCoordinateHeights=function(){return this._heightQuads&&0!=this._heightQuads.length||this._initHeightQuads(),this._computeHeightQuads(),this},i.prototype._getFacetAt=function(e,t){var i=Math.floor((e+this._maxX)*this._subdivisionsX/this._width),r=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),n=this._heightQuads[r*this._subdivisionsX+i];return t4&&(s.push(e.VertexBuffer.MatricesIndicesExtraKind),s.push(e.VertexBuffer.MatricesWeightsExtraKind)),o.push("#define NUM_BONE_INFLUENCERS "+t.numBoneInfluencers),o.push("#define BonesPerMesh "+(t.skeleton.bones.length+1)),a.addCPUSkinningFallback(0,t),-1===this._options.uniforms.indexOf("mBones")&&this._options.uniforms.push("mBones")):o.push("#define NUM_BONE_INFLUENCERS 0");for(var h in this._textures)if(!this._textures[h].isReady())return!1;n.getAlphaTesting()&&o.push("#define ALPHATEST");var u=this._effect,c=o.join("\n");return this._effect=n.createEffect(this._shaderPath,{attributes:s,uniformsNames:this._options.uniforms,uniformBuffersNames:this._options.uniformBuffers,samplers:this._options.samplers,defines:c,fallbacks:a,onCompiled:this.onCompiled,onError:this.onError},n),!!this._effect.isReady()&&(u!==this._effect&&r.resetCachedMaterial(),this._renderId=r.getRenderId(),!0)},i.prototype.bindOnlyWorldMatrix=function(e){var t=this.getScene();this._effect&&(-1!==this._options.uniforms.indexOf("world")&&this._effect.setMatrix("world",e),-1!==this._options.uniforms.indexOf("worldView")&&(e.multiplyToRef(t.getViewMatrix(),this._cachedWorldViewMatrix),this._effect.setMatrix("worldView",this._cachedWorldViewMatrix)),-1!==this._options.uniforms.indexOf("worldViewProjection")&&this._effect.setMatrix("worldViewProjection",e.multiply(t.getTransformMatrix())))},i.prototype.bind=function(t,i){if(this.bindOnlyWorldMatrix(t),this._effect&&this.getScene().getCachedMaterial()!==this){-1!==this._options.uniforms.indexOf("view")&&this._effect.setMatrix("view",this.getScene().getViewMatrix()),-1!==this._options.uniforms.indexOf("projection")&&this._effect.setMatrix("projection",this.getScene().getProjectionMatrix()),-1!==this._options.uniforms.indexOf("viewProjection")&&this._effect.setMatrix("viewProjection",this.getScene().getTransformMatrix()),e.MaterialHelper.BindBonesParameters(i,this._effect);var r;for(r in this._textures)this._effect.setTexture(r,this._textures[r]);for(r in this._textureArrays)this._effect.setTextureArray(r,this._textureArrays[r]);for(r in this._floats)this._effect.setFloat(r,this._floats[r]);for(r in this._floatsArrays)this._effect.setArray(r,this._floatsArrays[r]);for(r in this._colors3)this._effect.setColor3(r,this._colors3[r]);for(r in this._colors3Arrays)this._effect.setArray3(r,this._colors3Arrays[r]);for(r in this._colors4){var n=this._colors4[r];this._effect.setFloat4(r,n.r,n.g,n.b,n.a)}for(r in this._vectors2)this._effect.setVector2(r,this._vectors2[r]);for(r in this._vectors3)this._effect.setVector3(r,this._vectors3[r]);for(r in this._vectors4)this._effect.setVector4(r,this._vectors4[r]);for(r in this._matrices)this._effect.setMatrix(r,this._matrices[r]);for(r in this._matrices3x3)this._effect.setMatrix3x3(r,this._matrices3x3[r]);for(r in this._matrices2x2)this._effect.setMatrix2x2(r,this._matrices2x2[r]);for(r in this._vectors3Arrays)this._effect.setArray3(r,this._vectors3Arrays[r])}this._afterBind(i)},i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);for(var i in this._textures)e.push(this._textures[i]);for(var i in this._textureArrays)for(var r=this._textureArrays[i],n=0;ne.Tmp.Vector3[1].x&&(e.Tmp.Vector3[1].x=l[c].x),l[c].ye.Tmp.Vector3[1].y&&(e.Tmp.Vector3[1].y=l[c].y),l[c].ze.Tmp.Vector3[1].z&&(e.Tmp.Vector3[1].z=l[c].z),c++,r+=3;h._closePath&&(t[r]=l[0].x,t[r+1]=l[0].y,t[r+2]=l[0].z,r+=3)}}(c),h._boundingInfo=new e.BoundingInfo(e.Tmp.Vector3[0],e.Tmp.Vector3[1]),h._boundingInfo.update(h._worldMatrix),h.updateVerticesData(e.VertexBuffer.PositionKind,c,!1,!1),r.colors){for(var f=h.getVerticesData(e.VertexBuffer.ColorKind),d=0;d1?1:r.arc:1,a=void 0===r.closed||r.closed,l=r.shape,h=r.radius||1,u=r.tessellation||64,c=r.updatable,f=t.updateSideOrientation(r.sideOrientation),d=r.cap||e.Mesh.NO_CAP,p=2*Math.PI,_=new Array,m=r.invertUV||!1,g=0,v=0,y=p/u*s,b=new Array;for(g=0;g<=u;g++){var b=[];for(d!=e.Mesh.CAP_START&&d!=e.Mesh.CAP_ALL||(b.push(new e.Vector3(0,l[0].y,0)),b.push(new e.Vector3(Math.cos(g*y)*l[0].x*h,l[0].y,Math.sin(g*y)*l[0].x*h))),v=0;v1)?1:r.arc||1;var p,_,m=function(t,i,r,n,o,s,a,l){for(var h,u,c,f,d=i.getTangents(),p=i.getNormals(),_=i.getDistances(),m=2*Math.PI,g=m/o*l,v=function(){return n},y=s||v,b=e.Tmp.Matrix[0],x=a===e.Mesh._NO_CAP||a===e.Mesh.CAP_END?0:2,T=0;T3?0:u,_=m(o,p,v,a,l,h,u,r.arc);var y=t.CreateRibbon(i,{pathArray:_,closePath:!0,closeArray:!1,updatable:f,sideOrientation:d,invertUV:c,frontUVs:r.frontUVs,backUVs:r.backUVs},n);return y.pathArray=_,y.path3D=p,y.tessellation=l,y.cap=u,y.arc=r.arc,y.radius=a,y},t.CreatePolyhedron=function(i,r,n){var o=new e.Mesh(i,n);return r.sideOrientation=t.updateSideOrientation(r.sideOrientation),o._originalBuilderSideOrientation=r.sideOrientation,e.VertexData.CreatePolyhedron(r).applyToMesh(o,r.updatable),o},t.CreateDecal=function(t,i,r){var n=i.getIndices(),o=i.getVerticesData(e.VertexBuffer.PositionKind),s=i.getVerticesData(e.VertexBuffer.NormalKind),a=r.position||e.Vector3.Zero(),l=r.normal||e.Vector3.Up(),h=r.size||e.Vector3.One(),u=r.angle||0;if(!l){var c=new e.Vector3(0,0,1),f=i.getScene().activeCamera,d=e.Vector3.TransformCoordinates(c,f.getWorldMatrix());l=f.globalPosition.subtract(d)}var p=-Math.atan2(l.z,l.x)-Math.PI/2,_=Math.sqrt(l.x*l.x+l.z*l.z),m=Math.atan2(l.y,_),g=e.Matrix.RotationYawPitchRoll(p,m,u).multiply(e.Matrix.Translation(a.x,a.y,a.z)),v=e.Matrix.Invert(g),y=i.getWorldMatrix(),b=y.multiply(v),x=new e.VertexData;x.indices=[],x.positions=[],x.normals=[],x.uvs=[];for(var T=0,A=function(t){var i=new e.PositionNormalVertex;if(!n||!o||!s)return i;var r=n[t];return i.position=new e.Vector3(o[3*r],o[3*r+1],o[3*r+2]),i.position=e.Vector3.TransformCoordinates(i.position,b),i.normal=new e.Vector3(s[3*r],s[3*r+1],s[3*r+2]),i.normal=e.Vector3.TransformNormal(i.normal,b),i},E=function(t,i){if(0===t.length)return t;for(var r=.5*Math.abs(e.Vector3.Dot(h,i)),n=function(t,n){var o=e.Vector3.GetClipFactor(t.position,n.position,i,r);return new e.PositionNormalVertex(e.Vector3.Lerp(t.position,n.position,o),e.Vector3.Lerp(t.normal,n.normal,o))},o=new Array,s=0;s0,l=m>0,u=g>0,(a?1:0)+(l?1:0)+(u?1:0)){case 0:o.push(t[s]),o.push(t[s+1]),o.push(t[s+2]);break;case 1:if(a&&(c=t[s+1],f=t[s+2],d=n(t[s],c),p=n(t[s],f)),l){c=t[s],f=t[s+2],d=n(t[s+1],c),p=n(t[s+1],f),o.push(d),o.push(f.clone()),o.push(c.clone()),o.push(f.clone()),o.push(d.clone()),o.push(p);break}u&&(c=t[s],f=t[s+1],d=n(t[s+2],c),p=n(t[s+2],f)),c&&f&&d&&p&&(o.push(c.clone()),o.push(f.clone()),o.push(d),o.push(p),o.push(d.clone()),o.push(f.clone()));break;case 2:a||(c=t[s].clone(),f=n(c,t[s+1]),d=n(c,t[s+2]),o.push(c),o.push(f),o.push(d)),l||(c=t[s+1].clone(),f=n(c,t[s+2]),d=n(c,t[s]),o.push(c),o.push(f),o.push(d)),u||(c=t[s+2].clone(),f=n(c,t[s]),d=n(c,t[s+1]),o.push(c),o.push(f),o.push(d))}}return o},P=0;P3?0:c,x=T(r,n,b,A,o,s,a,l,c,f);var E=t.CreateRibbon(i,{pathArray:x,closeArray:h,closePath:u,updatable:p,sideOrientation:_,invertUV:g,frontUVs:v||void 0,backUVs:y||void 0},d);return E.pathArray=x,E.path3D=b,E.cap=c,E},t})();e.MeshBuilder=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._audioContext=null,this._audioContextInitialized=!1,this.canUseWebAudio=!1,this.WarnedWebAudioUnsupported=!1,this.unlocked=!1,this.isMP3supported=!1,this.isOGGsupported=!1,void 0===window.AudioContext&&void 0===window.webkitAudioContext||(window.AudioContext=window.AudioContext||window.webkitAudioContext,this.canUseWebAudio=!0);var e=document.createElement("audio");try{e&&e.canPlayType&&e.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/,"")&&(this.isMP3supported=!0)}catch(e){}try{e&&e.canPlayType&&e.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(this.isOGGsupported=!0)}catch(e){}/iPad|iPhone|iPod/.test(navigator.platform)?this._unlockiOSaudio():this.unlocked=!0}return Object.defineProperty(t.prototype,"audioContext",{get:function(){return this._audioContextInitialized||this._initializeAudioContext(),this._audioContext},enumerable:!0,configurable:!0}),t.prototype._unlockiOSaudio=function(){var e=this,t=function(){if(e.audioContext){var i=e.audioContext.createBuffer(1,1,22050),r=e.audioContext.createBufferSource();r.buffer=i,r.connect(e.audioContext.destination),r.start(0),setTimeout((function(){r.playbackState!==r.PLAYING_STATE&&r.playbackState!==r.FINISHED_STATE||(e.unlocked=!0,window.removeEventListener("touchend",t,!1),e.onAudioUnlocked&&e.onAudioUnlocked())}),0)}};window.addEventListener("touchend",t,!1)},t.prototype._initializeAudioContext=function(){try{this.canUseWebAudio&&(this._audioContext=new AudioContext,this.masterGain=this._audioContext.createGain(),this.masterGain.gain.value=1,this.masterGain.connect(this._audioContext.destination),this._audioContextInitialized=!0)}catch(t){this.canUseWebAudio=!1,e.Tools.Error("Web Audio: "+t.message)}},t.prototype.dispose=function(){this.canUseWebAudio&&this._audioContextInitialized&&(this._connectedAnalyser&&this._audioContext&&(this._connectedAnalyser.stopDebugCanvas(),this._connectedAnalyser.dispose(),this.masterGain.disconnect(),this.masterGain.connect(this._audioContext.destination),this._connectedAnalyser=null),this.masterGain.gain.value=1),this.WarnedWebAudioUnsupported=!1},t.prototype.getGlobalVolume=function(){return this.canUseWebAudio&&this._audioContextInitialized?this.masterGain.gain.value:-1},t.prototype.setGlobalVolume=function(e){this.canUseWebAudio&&this._audioContextInitialized&&(this.masterGain.gain.value=e)},t.prototype.connectToAnalyser=function(e){this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas(),this.canUseWebAudio&&this._audioContextInitialized&&this._audioContext&&(this._connectedAnalyser=e,this.masterGain.disconnect(),this._connectedAnalyser.connectAudioNodes(this.masterGain,this._audioContext.destination))},t})();e.AudioEngine=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r,n,o){void 0===n&&(n=null);var s=this;if(this.autoplay=!1,this.loop=!1,this.useCustomAttenuation=!1,this.spatialSound=!1,this.refDistance=1,this.rolloffFactor=1,this.maxDistance=100,this.distanceModel="linear",this._panningModel="equalpower",this._playbackRate=1,this._streaming=!1,this._startTime=0,this._startOffset=0,this._position=e.Vector3.Zero(),this._localDirection=new e.Vector3(1,0,0),this._volume=1,this._isLoaded=!1,this._isReadyToPlay=!1,this.isPlaying=!1,this.isPaused=!1,this._isDirectional=!1,this._coneInnerAngle=360,this._coneOuterAngle=360,this._coneOuterGain=0,this._isOutputConnected=!1,this._urlType="Unknown",this.name=t,this._scene=r,this._readyToPlayCallback=n,this._customAttenuationFunction=function(e,t,i,r,n){return t0&&(h=!0,this._soundLoaded(i));break;case"String":l.push(i);case"Array":0===l.length&&(l=i);for(var u=0;u0&&(this._htmlAudioElement.currentTime=0);else if(e.Engine.audioEngine.audioContext&&this._soundSource){var i=t?e.Engine.audioEngine.audioContext.currentTime+t:e.Engine.audioEngine.audioContext.currentTime;this._soundSource.stop(i),this._soundSource.onended=function(){},this.isPaused||(this._startOffset=0)}this.isPlaying=!1}},t.prototype.pause=function(){this.isPlaying&&(this.isPaused=!0,this._streaming?this._htmlAudioElement.pause():e.Engine.audioEngine.audioContext&&(this.stop(0),this._startOffset+=e.Engine.audioEngine.audioContext.currentTime-this._startTime))},t.prototype.setVolume=function(t,i){e.Engine.audioEngine.canUseWebAudio&&this._soundGain&&(i&&e.Engine.audioEngine.audioContext?(this._soundGain.gain.cancelScheduledValues(e.Engine.audioEngine.audioContext.currentTime),this._soundGain.gain.setValueAtTime(this._soundGain.gain.value,e.Engine.audioEngine.audioContext.currentTime),this._soundGain.gain.linearRampToValueAtTime(t,e.Engine.audioEngine.audioContext.currentTime+i)):this._soundGain.gain.value=t),this._volume=t},t.prototype.setPlaybackRate=function(e){this._playbackRate=e,this.isPlaying&&(this._streaming?this._htmlAudioElement.playbackRate=this._playbackRate:this._soundSource&&(this._soundSource.playbackRate.value=this._playbackRate))},t.prototype.getVolume=function(){return this._volume},t.prototype.attachToMesh=function(e){var t=this;this._connectedMesh&&this._registerFunc&&(this._connectedMesh.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null),this._connectedMesh=e,this.spatialSound||(this.spatialSound=!0,this._createSpatialParameters(),this.isPlaying&&this.loop&&(this.stop(),this.play())),this._onRegisterAfterWorldMatrixUpdate(this._connectedMesh),this._registerFunc=function(e){return t._onRegisterAfterWorldMatrixUpdate(e)},e.registerAfterWorldMatrixUpdate(this._registerFunc)},t.prototype.detachFromMesh=function(){this._connectedMesh&&this._registerFunc&&(this._connectedMesh.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null,this._connectedMesh=null)},t.prototype._onRegisterAfterWorldMatrixUpdate=function(t){var i=t.getBoundingInfo();this.setPosition(i.boundingSphere.centerWorld),e.Engine.audioEngine.canUseWebAudio&&this._isDirectional&&this.isPlaying&&this._updateDirection()},t.prototype.clone=function(){var e=this;if(this._streaming)return null;var i=function(){e._isReadyToPlay?(n._audioBuffer=e.getAudioBuffer(),n._isReadyToPlay=!0,n.autoplay&&n.play()):window.setTimeout(i,300)},r={autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this.spatialSound,maxDistance:this.maxDistance,useCustomAttenuation:this.useCustomAttenuation,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel},n=new t(this.name+"_cloned",new ArrayBuffer(0),this._scene,null,r);return this.useCustomAttenuation&&n.setAttenuationFunction(this._customAttenuationFunction),n.setPosition(this._position),n.setPlaybackRate(this._playbackRate),i(),n},t.prototype.getAudioBuffer=function(){return this._audioBuffer},t.prototype.serialize=function(){var e={name:this.name,url:this.name,autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this.spatialSound,maxDistance:this.maxDistance,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel,playbackRate:this._playbackRate,panningModel:this._panningModel,soundTrackId:this.soundTrackId};return this.spatialSound&&(this._connectedMesh&&(e.connectedMeshId=this._connectedMesh.id),e.position=this._position.asArray(),e.refDistance=this.refDistance,e.distanceModel=this.distanceModel,e.isDirectional=this._isDirectional,e.localDirectionToMesh=this._localDirection.asArray(),e.coneInnerAngle=this._coneInnerAngle,e.coneOuterAngle=this._coneOuterAngle,e.coneOuterGain=this._coneOuterGain),e},t.Parse=function(i,r,n,o){var s,a=i.name;s=i.url?n+i.url:n+a;var l,h={autoplay:i.autoplay,loop:i.loop,volume:i.volume,spatialSound:i.spatialSound,maxDistance:i.maxDistance,rolloffFactor:i.rolloffFactor,refDistance:i.refDistance,distanceModel:i.distanceModel,playbackRate:i.playbackRate};if(o){var u=function(){o._isReadyToPlay?(l._audioBuffer=o.getAudioBuffer(),l._isReadyToPlay=!0,l.autoplay&&l.play()):window.setTimeout(u,300)};l=new t(a,new ArrayBuffer(0),r,null,h),u()}else l=new t(a,s,r,function(){r._removePendingData(l)},h),r._addPendingData(l);if(i.position){var c=e.Vector3.FromArray(i.position);l.setPosition(c)}if(i.isDirectional&&(l.setDirectionalCone(i.coneInnerAngle||360,i.coneOuterAngle||360,i.coneOuterGain||0),i.localDirectionToMesh)){var f=e.Vector3.FromArray(i.localDirectionToMesh);l.setLocalDirectionToMesh(f)}if(i.connectedMeshId){var d=r.getMeshByID(i.connectedMeshId);d&&l.attachToMesh(d)}return l},t})();e.Sound=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t){this.id=-1,this._isMainTrack=!1,this._isInitialized=!1,this._scene=e,this.soundCollection=new Array,this._options=t,this._isMainTrack||(this._scene.soundTracks.push(this),this.id=this._scene.soundTracks.length-1)}return t.prototype._initializeSoundTrackAudioGraph=function(){e.Engine.audioEngine.canUseWebAudio&&e.Engine.audioEngine.audioContext&&(this._outputAudioNode=e.Engine.audioEngine.audioContext.createGain(),this._outputAudioNode.connect(e.Engine.audioEngine.masterGain),this._options&&(this._options.volume&&(this._outputAudioNode.gain.value=this._options.volume),this._options.mainTrack&&(this._isMainTrack=this._options.mainTrack)),this._isInitialized=!0)},t.prototype.dispose=function(){if(e.Engine.audioEngine.canUseWebAudio){for(this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas();this.soundCollection.length;)this.soundCollection[0].dispose();this._outputAudioNode&&this._outputAudioNode.disconnect(),this._outputAudioNode=null}},t.prototype.AddSound=function(t){this._isInitialized||this._initializeSoundTrackAudioGraph(),e.Engine.audioEngine.canUseWebAudio&&this._outputAudioNode&&t.connectToSoundTrackAudioNode(this._outputAudioNode),t.soundTrackId&&(-1===t.soundTrackId?this._scene.mainSoundTrack.RemoveSound(t):this._scene.soundTracks[t.soundTrackId].RemoveSound(t)),this.soundCollection.push(t),t.soundTrackId=this.id},t.prototype.RemoveSound=function(e){var t=this.soundCollection.indexOf(e);-1!==t&&this.soundCollection.splice(t,1)},t.prototype.setVolume=function(t){e.Engine.audioEngine.canUseWebAudio&&this._outputAudioNode&&(this._outputAudioNode.gain.value=t)},t.prototype.switchPanningModelToHRTF=function(){if(e.Engine.audioEngine.canUseWebAudio)for(var t=0;t0&&(this._postProcesses[0].autoClear=!1))}},i.prototype._shouldRender=function(){return-1===this._currentRefreshId?(this._currentRefreshId=1,!0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)},i.prototype.getRenderSize=function(){return this._size.width?this._size.width:this._size},i.prototype.getRenderWidth=function(){return this._size.width?this._size.width:this._size},i.prototype.getRenderHeight=function(){return this._size.width?this._size.height:this._size},Object.defineProperty(i.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),i.prototype.scale=function(e){var t=this.getRenderSize()*e;this.resize(t)},i.prototype.getReflectionTextureMatrix=function(){return this.isCube?this._textureMatrix:t.prototype.getReflectionTextureMatrix.call(this)},i.prototype.resize=function(e){this.releaseInternalTexture();var t=this.getScene();t&&(this._processSizeParameter(e),this.isCube?this._texture=t.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions):this._texture=t.getEngine().createRenderTargetTexture(this._size,this._renderTargetOptions))},i.prototype.render=function(e,t){void 0===e&&(e=!1),void 0===t&&(t=!1);var i=this.getScene();if(i){var r=i.getEngine();if(void 0!==this.useCameraPostProcesses&&(e=this.useCameraPostProcesses),this._waitingRenderList){this.renderList=[];for(var n=0;n=0&&this._renderingManager.dispatchParticles(v))}if(this.isCube)for(var b=0;b<6;b++)this.renderToTarget(b,u,c,e,t),i.incrementRenderId(),i.resetCachedMaterial();else this.renderToTarget(0,u,c,e,t);this.onAfterUnbindObservable.notifyObservers(this),i.activeCamera&&(this.activeCamera&&this.activeCamera!==i.activeCamera&&i.setTransformMatrix(i.activeCamera.getViewMatrix(),i.activeCamera.getProjectionMatrix(!0)),r.setViewport(i.activeCamera.viewport)),i.resetCachedMaterial()}},i.prototype._bestReflectionRenderTargetDimension=function(t,i){var r=t*i,n=e.Tools.NearestPOT(r+16384/(128+r));return Math.min(e.Tools.FloorPOT(t),n)},i.prototype.renderToTarget=function(t,i,r,n,o){var s=this,a=this.getScene();if(a){var l=a.getEngine();this._texture&&(this._postProcessManager?this._postProcessManager._prepareFrame(this._texture,this._postProcesses):n&&a.postProcessManager._prepareFrame(this._texture)||this._texture&&l.bindFramebuffer(this._texture,this.isCube?t:void 0,void 0,void 0,this.ignoreCameraViewport),this.onBeforeRenderObservable.notifyObservers(t),this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(l):l.clear(this.clearColor||a.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||a.updateTransformMatrix(!0),this._renderingManager.render(this.customRenderFunction,i,this.renderParticles,this.renderSprites),this._postProcessManager?this._postProcessManager._finalizeFrame(!1,this._texture,t,this._postProcesses,this.ignoreCameraViewport):n&&a.postProcessManager._finalizeFrame(!1,this._texture,t),this._doNotChangeAspectRatio||a.updateTransformMatrix(!0),o&&e.Tools.DumpFramebuffer(this.getRenderWidth(),this.getRenderHeight(),l),this.isCube&&5!==t?this.onAfterRenderObservable.notifyObservers(t):(this.isCube&&5===t&&l.generateMipMapsForCubemap(this._texture),l.unBindFramebuffer(this._texture,this.isCube,(function(){s.onAfterRenderObservable.notifyObservers(t)}))))}},i.prototype.setRenderingOrder=function(e,t,i,r){void 0===t&&(t=null),void 0===i&&(i=null),void 0===r&&(r=null),this._renderingManager.setRenderingOrder(e,t,i,r)},i.prototype.setRenderingAutoClearDepthStencil=function(e,t){this._renderingManager.setRenderingAutoClearDepthStencil(e,t)},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._renderTargetOptions.generateMipMaps,this._doNotChangeAspectRatio,this._renderTargetOptions.type,this.isCube,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer,this._renderTargetOptions.generateStencilBuffer) ;return t.hasAlpha=this.hasAlpha,t.level=this.level,t.coordinatesMode=this.coordinatesMode,this.renderList&&(t.renderList=this.renderList.slice(0)),t},i.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);if(e.renderTargetSize=this.getRenderSize(),e.renderList=[],this.renderList)for(var i=0;i=0&&e.customRenderTargets.splice(i,1);for(var r=0,n=e.cameras;r=0&&o.customRenderTargets.splice(i,1)}t.prototype.dispose.call(this)}},i.prototype._rebuild=function(){this.refreshRate===i.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=i.REFRESHRATE_RENDER_ONCE),this._postProcessManager&&this._postProcessManager._rebuild()},i._REFRESHRATE_RENDER_ONCE=0,i._REFRESHRATE_RENDER_ONEVERYFRAME=1,i._REFRESHRATE_RENDER_ONEVERYTWOFRAMES=2,i})(e.Texture);e.RenderTargetTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s){var a=this;s=s||{};var l=!!s.generateMipMaps&&s.generateMipMaps,h=!!s.generateDepthTexture&&s.generateDepthTexture,u=void 0===s.doNotChangeAspectRatio||s.doNotChangeAspectRatio;if(a=t.call(this,i,r,o,l,u)||this,a._engine=o.getEngine(),!a.isSupported)return void a.dispose();for(var c=[],f=[],d=0;d1||this._engine.getCaps().drawBuffersExtension},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"textures",{get:function(){return this._textures},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"depthTexture",{get:function(){return this._textures[this._textures.length-1]},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"wrapU",{set:function(e){if(this._textures)for(var t=0;t=0;e--)void 0!==this._internalTextures[e]&&(this._internalTextures[e].dispose(),this._internalTextures.splice(e,1))},i})(e.RenderTargetTexture);e.MultiRenderTarget=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a,l){void 0===s&&(s=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===a&&(a=e.Texture.BILINEAR_SAMPLINGMODE),void 0===l&&(l=!0);var h=t.call(this,i,r,n,o,!0,s,!1,a,l)||this;return h.mirrorPlane=new e.Plane(0,1,0,1),h._transformMatrix=e.Matrix.Zero(),h._mirrorMatrix=e.Matrix.Zero(),h._adaptiveBlurKernel=0,h._blurKernelX=0,h._blurKernelY=0,h._blurRatio=1,h.ignoreCameraViewport=!0,h.onBeforeRenderObservable.add((function(){e.Matrix.ReflectionToRef(h.mirrorPlane,h._mirrorMatrix),h._savedViewMatrix=n.getViewMatrix(),h._mirrorMatrix.multiplyToRef(h._savedViewMatrix,h._transformMatrix),n.setTransformMatrix(h._transformMatrix,n.getProjectionMatrix()),n.clipPlane=h.mirrorPlane,n.getEngine().cullBackFaces=!1,n._mirroredCameraPosition=e.Vector3.TransformCoordinates(n.activeCamera.globalPosition,h._mirrorMatrix)})),h.onAfterRenderObservable.add((function(){n.setTransformMatrix(h._savedViewMatrix,n.getProjectionMatrix()),n.getEngine().cullBackFaces=!0,n._mirroredCameraPosition=null,delete n.clipPlane})),h}return __extends(i,t),Object.defineProperty(i.prototype,"blurRatio",{get:function(){return this._blurRatio},set:function(e){this._blurRatio!==e&&(this._blurRatio=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"adaptiveBlurKernel",{set:function(e){this._adaptiveBlurKernel=e,this._autoComputeBlurKernel()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"blurKernel",{set:function(e){this.blurKernelX=e,this.blurKernelY=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"blurKernelX",{get:function(){return this._blurKernelX},set:function(e){this._blurKernelX!==e&&(this._blurKernelX=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"blurKernelY",{get:function(){return this._blurKernelY},set:function(e){this._blurKernelY!==e&&(this._blurKernelY=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),i.prototype._autoComputeBlurKernel=function(){var e=this.getScene().getEngine(),t=this.getRenderWidth()/e.getRenderWidth(),i=this.getRenderHeight()/e.getRenderHeight();this.blurKernelX=this._adaptiveBlurKernel*t,this.blurKernelY=this._adaptiveBlurKernel*i},i.prototype._onRatioRescale=function(){this._sizeRatio&&(this.resize(this._initialSizeParameter),this._adaptiveBlurKernel||this._preparePostProcesses()),this._adaptiveBlurKernel&&this._autoComputeBlurKernel()},i.prototype._preparePostProcesses=function(){if(this.clearPostProcesses(!0),this._blurKernelX&&this._blurKernelY){var t=this.getScene().getEngine(),i=t.getCaps().textureFloatRender?e.Engine.TEXTURETYPE_FLOAT:e.Engine.TEXTURETYPE_HALF_FLOAT;this._blurX=new e.BlurPostProcess("horizontal blur",new e.Vector2(1,0),this._blurKernelX,this._blurRatio,null,e.Texture.BILINEAR_SAMPLINGMODE,t,!1,i),this._blurX.autoClear=!1,1===this._blurRatio&&this.samples<2&&this._texture?this._blurX.outputTexture=this._texture:this._blurX.alwaysForcePOT=!0,this._blurY=new e.BlurPostProcess("vertical blur",new e.Vector2(0,1),this._blurKernelY,this._blurRatio,null,e.Texture.BILINEAR_SAMPLINGMODE,t,!1,i),this._blurY.autoClear=!1,this._blurY.alwaysForcePOT=1!==this._blurRatio,this.addPostProcess(this._blurX),this.addPostProcess(this._blurY)}else this._blurY&&(this.removePostProcess(this._blurY),this._blurY.dispose(),this._blurY=null),this._blurX&&(this.removePostProcess(this._blurX),this._blurX.dispose(),this._blurX=null)},i.prototype.clone=function(){var e=this.getScene();if(!e)return this;var t=this.getSize(),r=new i(this.name,t.width,e,this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);return r.hasAlpha=this.hasAlpha,r.level=this.level,r.mirrorPlane=this.mirrorPlane.clone(),this.renderList&&(r.renderList=this.renderList.slice(0)),r},i.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);return e.mirrorPlane=this.mirrorPlane.asArray(),e},i})(e.RenderTargetTexture);e.MirrorTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o){var s=t.call(this,i,r,n,o,!0)||this;return s.refractionPlane=new e.Plane(0,1,0,1),s.depth=2,s.onBeforeRenderObservable.add((function(){n.clipPlane=s.refractionPlane})),s.onAfterRenderObservable.add((function(){delete n.clipPlane})),s}return __extends(i,t),i.prototype.clone=function(){var e=this.getScene();if(!e)return this;var t=this.getSize(),r=new i(this.name,t.width,e,this._generateMipMaps);return r.hasAlpha=this.hasAlpha,r.level=this.level,r.refractionPlane=this.refractionPlane.clone(),this.renderList&&(r.renderList=this.renderList.slice(0)),r.depth=this.depth,r},i.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);return e.mirrorPlane=this.refractionPlane.asArray(),e.depth=this.depth,e},i})(e.RenderTargetTexture);e.RefractionTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a){void 0===n&&(n=null),void 0===s&&(s=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===a&&(a=e.Engine.TEXTUREFORMAT_RGBA);var l=t.call(this,null,n,!o,void 0,s,void 0,void 0,void 0,void 0,a)||this;l.name=i,l._engine=l.getScene().getEngine(),l.wrapU=e.Texture.CLAMP_ADDRESSMODE,l.wrapV=e.Texture.CLAMP_ADDRESSMODE,l._generateMipMaps=o,r.getContext?(l._canvas=r,l._texture=l._engine.createDynamicTexture(r.width,r.height,o,s)):(l._canvas=document.createElement("canvas"),r.width?l._texture=l._engine.createDynamicTexture(r.width,r.height,o,s):l._texture=l._engine.createDynamicTexture(r,r,o,s));var h=l.getSize();return l._canvas.width=h.width,l._canvas.height=h.height,l._context=l._canvas.getContext("2d"),l}return __extends(i,t),Object.defineProperty(i.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),i.prototype._recreate=function(e){this._canvas.width=e.width,this._canvas.height=e.height,this.releaseInternalTexture(),this._texture=this._engine.createDynamicTexture(e.width,e.height,this._generateMipMaps,this._samplingMode)},i.prototype.scale=function(e){var t=this.getSize();t.width*=e,t.height*=e,this._recreate(t)},i.prototype.scaleTo=function(e,t){var i=this.getSize();i.width=e,i.height=t,this._recreate(i)},i.prototype.getContext=function(){return this._context},i.prototype.clear=function(){var e=this.getSize();this._context.fillRect(0,0,e.width,e.height)},i.prototype.update=function(e){this._engine.updateDynamicTexture(this._texture,this._canvas,void 0===e||e,void 0,this._format||void 0)},i.prototype.drawText=function(e,t,i,r,n,o,s,a){void 0===a&&(a=!0);var l=this.getSize();if(o&&(this._context.fillStyle=o,this._context.fillRect(0,0,l.width,l.height)),this._context.font=r,null===t||void 0===t){var h=this._context.measureText(e);t=(l.width-h.width)/2}if(null===i||void 0===i){var u=parseInt(r.replace(/\D/g,""));i=l.height/2+u/3.65}this._context.fillStyle=n,this._context.fillText(e,t,i),a&&this.update(s)},i.prototype.clone=function(){var e=this.getScene();if(!e)return this;var t=this.getSize(),r=new i(this.name,t,e,this._generateMipMaps);return r.hasAlpha=this.hasAlpha,r.level=this.level,r.wrapU=this.wrapU,r.wrapV=this.wrapV,r},i.prototype._rebuild=function(){this.update()},i})(e.Texture);e.DynamicTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a){void 0===o&&(o=!1),void 0===s&&(s=!1),void 0===a&&(a=e.Texture.TRILINEAR_SAMPLINGMODE);var l=t.call(this,null,n,!o,s)||this;l._autoLaunch=!0;var h=null;return l.name=i,r instanceof HTMLVideoElement?l.video=r:(h=r,l.video=document.createElement("video"),l.video.autoplay=!1,l.video.loop=!0),l._engine=l.getScene().getEngine(),l._generateMipMaps=o,l._samplingMode=a,!l._engine.needPOTTextures||e.Tools.IsExponentOfTwo(l.video.videoWidth)&&e.Tools.IsExponentOfTwo(l.video.videoHeight)?(l.wrapU=e.Texture.WRAP_ADDRESSMODE,l.wrapV=e.Texture.WRAP_ADDRESSMODE):(l.wrapU=e.Texture.CLAMP_ADDRESSMODE,l.wrapV=e.Texture.CLAMP_ADDRESSMODE,l._generateMipMaps=!1),h?(l.video.addEventListener("canplay",(function(){l._createTexture()})),h.forEach((function(e){var t=document.createElement("source");t.src=e,l.video.appendChild(t)}))):l._createTexture(),l._lastUpdate=e.Tools.Now,l}return __extends(i,t),i.prototype.__setTextureReady=function(){this._texture&&(this._texture.isReady=!0)},i.prototype._createTexture=function(){this._texture=this._engine.createDynamicTexture(this.video.videoWidth,this.video.videoHeight,this._generateMipMaps,this._samplingMode),this._autoLaunch&&(this._autoLaunch=!1,this.video.play()),this._setTextureReady=this.__setTextureReady.bind(this),this.video.addEventListener("playing",this._setTextureReady)},i.prototype._rebuild=function(){this.update()},i.prototype.update=function(){var t=e.Tools.Now;return!(t-this._lastUpdate<15||this.video.readyState!==this.video.HAVE_ENOUGH_DATA)&&(this._lastUpdate=t,this._engine.updateVideoTexture(this._texture,this.video,this._invertY),!0)},i.prototype.dispose=function(){t.prototype.dispose.call(this),this.video.removeEventListener("playing",this._setTextureReady)},i.CreateFromWebCam=function(t,i,r){var n,o=document.createElement("video");r&&r.deviceId&&(n={exact:r.deviceId}),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,navigator.getUserMedia&&navigator.getUserMedia({video:{deviceId:n,width:{min:r&&r.minWidth||256,max:r&&r.maxWidth||640},height:{min:r&&r.minHeight||256,max:r&&r.maxHeight||480}}},(function(r){void 0!==o.mozSrcObject?o.mozSrcObject=r:o.src=window.URL&&window.URL.createObjectURL(r)||r,o.play(),i&&i(new e.VideoTexture("video",o,t,!0,!0))}),(function(t){e.Tools.Error(t.name)}))},i})(e.Texture);e.VideoTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a,l,h){void 0===a&&(a=!0),void 0===l&&(l=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE);var u=t.call(this,null,s,!a,l)||this;return u.format=o,u._engine=s.getEngine(),u._texture=s.getEngine().createRawTexture(i,r,n,o,a,l,h),u.wrapU=e.Texture.CLAMP_ADDRESSMODE,u.wrapV=e.Texture.CLAMP_ADDRESSMODE,u}return __extends(i,t),i.prototype.update=function(e){this._engine.updateRawTexture(this._texture,e,this.format,this._invertY)},i.CreateLuminanceTexture=function(t,r,n,o,s,a,l){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_LUMINANCE,o,s,a,l)},i.CreateLuminanceAlphaTexture=function(t,r,n,o,s,a,l){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_LUMINANCE_ALPHA,o,s,a,l)},i.CreateAlphaTexture=function(t,r,n,o,s,a,l){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_ALPHA,o,s,a,l)},i.CreateRGBTexture=function(t,r,n,o,s,a,l){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_RGB,o,s,a,l)},i.CreateRGBATexture=function(t,r,n,o,s,a,l){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_RGBA,o,s,a,l)},i})(e.Texture);e.RawTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r,n,o,s,a,l,h,u,c,f,d,p){void 0===a&&(a=e.Texture.NEAREST_SAMPLINGMODE),void 0===u&&(u=null),void 0===c&&(c=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===f&&(f="postprocess"),void 0===p&&(p=!1),this.name=t,this.width=-1,this.height=-1,this.autoClear=!0,this.alphaMode=e.Engine.ALPHA_DISABLE,this.enablePixelPerfectMode=!1,this.scaleMode=e.Engine.SCALEMODE_FLOOR,this.alwaysForcePOT=!1,this.samples=1,this.adaptScaleToCurrentViewport=!1,this._reusable=!1,this._textures=new e.SmartArray(2),this._currentRenderTextureInd=0,this._scaleRatio=new e.Vector2(1,1),this._texelSize=e.Vector2.Zero(),this.onActivateObservable=new e.Observable,this.onSizeChangedObservable=new e.Observable,this.onApplyObservable=new e.Observable,this.onBeforeRenderObservable=new e.Observable,this.onAfterRenderObservable=new e.Observable,null!=s?(this._camera=s,this._scene=s.getScene(),s.attachPostProcess(this),this._engine=this._scene.getEngine(),this._scene.postProcesses.push(this)):l&&(this._engine=l,this._engine.postProcesses.push(this)),this._options=o,this.renderTargetSamplingMode=a||e.Texture.NEAREST_SAMPLINGMODE,this._reusable=h||!1,this._textureType=c,this._samplers=n||[],this._samplers.push("textureSampler"),this._fragmentUrl=i,this._vertexUrl=f,this._parameters=r||[],this._parameters.push("scale"),this._indexParameters=d,p||this.updateEffect(u)}return Object.defineProperty(t.prototype,"onActivate",{set:function(e){this._onActivateObserver&&this.onActivateObservable.remove(this._onActivateObserver),e&&(this._onActivateObserver=this.onActivateObservable.add(e))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onSizeChanged",{set:function(e){this._onSizeChangedObserver&&this.onSizeChangedObservable.remove(this._onSizeChangedObserver),this._onSizeChangedObserver=this.onSizeChangedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onApply",{set:function(e){this._onApplyObserver&&this.onApplyObservable.remove(this._onApplyObserver),this._onApplyObserver=this.onApplyObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"outputTexture",{get:function(){return this._textures.data[this._currentRenderTextureInd]},set:function(e){this._forcedOutputTexture=e},enumerable:!0,configurable:!0}),t.prototype.getCamera=function(){return this._camera},Object.defineProperty(t.prototype,"texelSize",{get:function(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.texelSize:(this._forcedOutputTexture&&this._texelSize.copyFromFloats(1/this._forcedOutputTexture.width,1/this._forcedOutputTexture.height),this._texelSize)},enumerable:!0,configurable:!0}),t.prototype.getEngine=function(){return this._engine},t.prototype.getEffect=function(){return this._effect},t.prototype.shareOutputWith=function(e){return this._disposeTextures(),this._shareOutputWithPostProcess=e,this},t.prototype.updateEffect=function(e,t,i,r,n,o){void 0===e&&(e=null),void 0===t&&(t=null),void 0===i&&(i=null),this._effect=this._engine.createEffect({vertex:this._vertexUrl,fragment:this._fragmentUrl},["position"],t||this._parameters,i||this._samplers,null!==e?e:"",void 0,n,o,r||this._indexParameters)},t.prototype.isReusable=function(){return this._reusable},t.prototype.markTextureDirty=function(){this.width=-1},t.prototype.activate=function(t,i,r){var n=this;void 0===i&&(i=null),t=t||this._camera;var o=t.getScene(),s=o.getEngine(),a=s.getCaps().maxTextureSize,l=(i?i.width:this._engine.getRenderWidth(!0))*this._options|0,h=(i?i.height:this._engine.getRenderHeight(!0))*this._options|0,u=this._options.width||l,c=this._options.height||h;if(!this._shareOutputWithPostProcess&&!this._forcedOutputTexture){if(this.adaptScaleToCurrentViewport){var f=s.currentViewport;f&&(u*=f.width,c*=f.height)}if((this.renderTargetSamplingMode===e.Texture.TRILINEAR_SAMPLINGMODE||this.alwaysForcePOT)&&(this._options.width||(u=s.needPOTTextures?e.Tools.GetExponentOfTwo(u,a,this.scaleMode):u),this._options.height||(c=s.needPOTTextures?e.Tools.GetExponentOfTwo(c,a,this.scaleMode):c)),this.width!==u||this.height!==c){if(this._textures.length>0){for(var d=0;d0)for(var e=0;e0&&this._camera._postProcesses[0].markTextureDirty(),this.onActivateObservable.clear(),this.onAfterRenderObservable.clear(),this.onApplyObservable.clear(),this.onBeforeRenderObservable.clear(),this.onSizeChangedObservable.clear()}},t})();e.PostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a,l){return void 0===l&&(l=e.Engine.TEXTURETYPE_UNSIGNED_INT),t.call(this,i,"pass",null,null,r,n,o,s,a,void 0,l)||this}return __extends(i,t),i})(e.PostProcess);e.PassPostProcess=t})(BABYLON||(BABYLON={}));var __assign=this&&this.__assign||Object.assign||function(e){for(var t,i=1,r=arguments.length;i=1?1:e<=0?0:e,this},t.prototype.setTransparencyShadow=function(e){return this._transparencyShadow=e,this},t.prototype.getShadowMap=function(){return this._shadowMap},t.prototype.getShadowMapForRendering=function(){return this._shadowMap2?this._shadowMap2:this._shadowMap},t.prototype.addShadowCaster=function(e,t){return void 0===t&&(t=!0),this._shadowMap?(this._shadowMap.renderList||(this._shadowMap.renderList=[]),this._shadowMap.renderList.push(e),t&&(i=this._shadowMap.renderList).push.apply(i,e.getChildMeshes()),this):this;var i},t.prototype.removeShadowCaster=function(e,t){if(void 0===t&&(t=!0),!this._shadowMap||!this._shadowMap.renderList)return this;var i=this._shadowMap.renderList.indexOf(e);if(-1!==i&&this._shadowMap.renderList.splice(i,1),t)for(var r=0,n=e.getChildren();r=s.length)return void(e&&e(i));setTimeout(c,16)}};c()},t.prototype.isReady=function(t,i){var r=[];this._textureType!==e.Engine.TEXTURETYPE_UNSIGNED_INT&&r.push("#define FLOAT"),(this.useExponentialShadowMap||this.useBlurExponentialShadowMap)&&r.push("#define ESM");var n=[e.VertexBuffer.PositionKind],o=t.getMesh(),s=t.getMaterial();if(s&&s.needAlphaTesting()){var a=s.getAlphaTestTexture();a&&(r.push("#define ALPHATEST"),o.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(n.push(e.VertexBuffer.UVKind),r.push("#define UV1")),o.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&1===a.coordinatesIndex&&(n.push(e.VertexBuffer.UV2Kind),r.push("#define UV2")))}o.useBones&&o.computeBonesUsingShaders?(n.push(e.VertexBuffer.MatricesIndicesKind),n.push(e.VertexBuffer.MatricesWeightsKind),o.numBoneInfluencers>4&&(n.push(e.VertexBuffer.MatricesIndicesExtraKind),n.push(e.VertexBuffer.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),r.push("#define BonesPerMesh "+(o.skeleton.bones.length+1))):r.push("#define NUM_BONE_INFLUENCERS 0"),i&&(r.push("#define INSTANCES"),n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"));var l=r.join("\n");return this._cachedDefines!==l&&(this._cachedDefines=l,this._effect=this._scene.getEngine().createEffect("shadowMap",n,["world","mBones","viewProjection","diffuseMatrix","lightPosition","depthValues","biasAndScale"],["diffuseSampler"],l)),this._effect.isReady()},t.prototype.prepareDefines=function(e,t){var i=this._scene,r=this._light;i.shadowsEnabled&&r.shadowEnabled&&(e["SHADOW"+t]=!0,this.usePoissonSampling?e["SHADOWPCF"+t]=!0:this.useExponentialShadowMap||this.useBlurExponentialShadowMap?e["SHADOWESM"+t]=!0:(this.useCloseExponentialShadowMap||this.useBlurCloseExponentialShadowMap)&&(e["SHADOWCLOSEESM"+t]=!0),r.needCube()&&(e["SHADOWCUBE"+t]=!0))},t.prototype.bindShadowLight=function(e,t){var i=this._light,r=this._scene;if(r.shadowsEnabled&&i.shadowEnabled){var n=r.activeCamera;if(n){var o=this.getShadowMap();o&&(i.needCube()||t.setMatrix("lightMatrix"+e,this.getTransformMatrix()),t.setTexture("shadowSampler"+e,this.getShadowMapForRendering()),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),this.blurScale/o.getSize().width,this.depthScale,this.frustumEdgeFalloff,e),i._uniformBuffer.updateFloat2("depthValues",this.getLight().getDepthMinZ(n),this.getLight().getDepthMinZ(n)+this.getLight().getDepthMaxZ(n),e))}}},t.prototype.getTransformMatrix=function(){var t=this._scene;if(this._currentRenderID===t.getRenderId()&&this._currentFaceIndexCache===this._currentFaceIndex)return this._transformMatrix;this._currentRenderID=t.getRenderId(),this._currentFaceIndexCache=this._currentFaceIndex;var i=this._light.position;if(this._light.computeTransformedInformation()&&(i=this._light.transformedPosition),e.Vector3.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex),this._lightDirection),1===Math.abs(e.Vector3.Dot(this._lightDirection,e.Vector3.Up()))&&(this._lightDirection.z=1e-13),this._light.needProjectionMatrixCompute()||!this._cachedPosition||!this._cachedDirection||!i.equals(this._cachedPosition)||!this._lightDirection.equals(this._cachedDirection)){this._cachedPosition=i.clone(),this._cachedDirection=this._lightDirection.clone(),e.Matrix.LookAtLHToRef(i,i.add(this._lightDirection),e.Vector3.Up(),this._viewMatrix);var r=this.getShadowMap();if(r){var n=r.renderList;n&&this._light.setShadowProjectionMatrix(this._projectionMatrix,this._viewMatrix,n)}this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix)}return this._transformMatrix},t.prototype.recreateShadowMap=function(){var e=this._shadowMap;if(e){var t=e.renderList;this._disposeRTTandPostProcesses(),this._initializeGenerator(),this.filter=this.filter,this._applyFilterValues(),this._shadowMap.renderList=t}},t.prototype._disposeBlurPostProcesses=function(){this._shadowMap2&&(this._shadowMap2.dispose(),this._shadowMap2=null),this._downSamplePostprocess&&(this._downSamplePostprocess.dispose(),this._downSamplePostprocess=null),this._boxBlurPostprocess&&(this._boxBlurPostprocess.dispose(),this._boxBlurPostprocess=null),this._kernelBlurXPostprocess&&(this._kernelBlurXPostprocess.dispose(),this._kernelBlurXPostprocess=null),this._kernelBlurYPostprocess&&(this._kernelBlurYPostprocess.dispose(),this._kernelBlurYPostprocess=null),this._blurPostProcesses=[]},t.prototype._disposeRTTandPostProcesses=function(){this._shadowMap&&(this._shadowMap.dispose(),this._shadowMap=null),this._disposeBlurPostProcesses()},t.prototype.dispose=function(){this._disposeRTTandPostProcesses(),this._light&&(this._light._shadowGenerator=null,this._light._markMeshesAsLightDirty())},t.prototype.serialize=function(){var e={},t=this.getShadowMap();if(!t)return e;if(e.lightId=this._light.id,e.mapSize=t.getRenderSize(),e.useExponentialShadowMap=this.useExponentialShadowMap,e.useBlurExponentialShadowMap=this.useBlurExponentialShadowMap,e.useCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.useBlurCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.usePoissonSampling=this.usePoissonSampling,e.forceBackFacesOnly=this.forceBackFacesOnly,e.depthScale=this.depthScale,e.darkness=this.getDarkness(),e.blurBoxOffset=this.blurBoxOffset,e.blurKernel=this.blurKernel,e.blurScale=this.blurScale,e.useKernelBlur=this.useKernelBlur,e.transparencyShadow=this._transparencyShadow,e.renderList=[],t.renderList)for(var i=0;i-1&&void 0!==d.skeletons&&null!==d.skeletons){if(!1===v.indexOf(b.skeletonId)>-1)for(var I=0,D=d.skeletons.length;I0){for(var se=0;se0){for(var le=0;le0&&this._textureLoadingCallback(e)}this._currentScene.render()}},t.prototype.drag=function(e){e.stopPropagation(),e.preventDefault()},t.prototype.drop=function(e){e.stopPropagation(),e.preventDefault(),this.loadFiles(e)},t.prototype._traverseFolder=function(e,t,i,r){var n=this,o=e.createReader(),s=e.fullPath.replace(/^\//,"").replace(/(.+?)\/?$/,"$1/");o.readEntries((function(e){i.count+=e.length;for(var o=0,a=e;o0){for(var i=new Array,r=[],n=e.dataTransfer?e.dataTransfer.items:null,o=0;o0&&(e.Tools.ClearLogCache(),e.Tools.Log("Babylon.js engine (v"+e.Engine.Version+") launched")),this._engine.stopRenderLoop(),this._currentScene.dispose()),e.SceneLoader.Load("file:",this._sceneFileToLoad,this._engine,(function(e){t._currentScene=e,t._sceneLoadedCallback&&t._sceneLoadedCallback(t._sceneFileToLoad,t._currentScene),t._currentScene.executeWhenReady((function(){t._engine.runRenderLoop((function(){t.renderFunction()}))}))}),(function(e){t._progressCallback&&t._progressCallback(e)}),(function(e,i){t._currentScene=e,t._errorCallback&&t._errorCallback(t._sceneFileToLoad,t._currentScene,i)}))):e.Tools.Error("Please provide a valid .babylon file.")},t.FilesToLoad={},t})();e.FilesInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this._count=0,this._data={}}return e.prototype.copyFrom=function(e){var t=this;this.clear(),e.forEach((function(e,i){return t.add(e,i)}))},e.prototype.get=function(e){var t=this._data[e];if(void 0!==t)return t},e.prototype.getOrAddWithFactory=function(e,t){var i=this.get(e);return void 0!==i?i:(i=t(e),i&&this.add(e,i),i)},e.prototype.getOrAdd=function(e,t){var i=this.get(e);return void 0!==i?i:(this.add(e,t),t)},e.prototype.contains=function(e){return void 0!==this._data[e]},e.prototype.add=function(e,t){return void 0===this._data[e]&&(this._data[e]=t,++this._count,!0)},e.prototype.set=function(e,t){return void 0!==this._data[e]&&(this._data[e]=t,!0)},e.prototype.getAndRemove=function(e){var t=this.get(e);return void 0!==t?(delete this._data[e],--this._count,t):null},e.prototype.remove=function(e){return!!this.contains(e)&&(delete this._data[e],--this._count,!0)},e.prototype.clear=function(){this._data={},this._count=0},Object.defineProperty(e.prototype,"count",{get:function(){return this._count},enumerable:!0,configurable:!0}),e.prototype.forEach=function(e){for(var t in this._data){e(t,this._data[t])}},e.prototype.first=function(e){for(var t in this._data){var i=this._data[t],r=e(t,i);if(r)return r}return null},e})();e.StringDictionary=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){}return t.EnableFor=function(e){e._tags=e._tags||{},e.hasTags=function(){return t.HasTags(e)},e.addTags=function(i){return t.AddTagsTo(e,i)},e.removeTags=function(i){return t.RemoveTagsFrom(e,i)},e.matchesTagsQuery=function(i){return t.MatchesQuery(e,i)}},t.DisableFor=function(e){delete e._tags,delete e.hasTags,delete e.addTags,delete e.removeTags,delete e.matchesTagsQuery},t.HasTags=function(t){return!!t._tags&&!e.Tools.IsEmpty(t._tags)},t.GetTags=function(e,t){if(void 0===t&&(t=!0),!e._tags)return null;if(t){var i=[];for(var r in e._tags)e._tags.hasOwnProperty(r)&&!0===e._tags[r]&&i.push(r);return i.join(" ")}return e._tags},t.AddTagsTo=function(e,i){if(i&&"string"==typeof i){i.split(" ").forEach((function(i,r,n){t._AddTagTo(e,i)}))}},t._AddTagTo=function(e,i){""!==(i=i.trim())&&"true"!==i&&"false"!==i&&(i.match(/[\s]/)||i.match(/^([!]|([|]|[&]){2})/)||(t.EnableFor(e),e._tags[i]=!0))},t.RemoveTagsFrom=function(e,i){if(t.HasTags(e)){var r=i.split(" ");for(var n in r)t._RemoveTagFrom(e,r[n])}},t._RemoveTagFrom=function(e,t){delete e._tags[t]},t.MatchesQuery=function(i,r){return void 0===r||(""===r?t.HasTags(i):e.Internals.AndOrNotEvaluator.Eval(r,(function(e){return t.HasTags(i)&&i._tags[e]})))},t})();e.Tags=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(e){var t=(function(){function e(){}return e.Eval=function(t,i){return"true"===(t=t.match(/\([^\(\)]*\)/g)?t.replace(/\([^\(\)]*\)/g,(function(t){return t=t.slice(1,t.length-1),e._HandleParenthesisContent(t,i)})):e._HandleParenthesisContent(t,i))||"false"!==t&&e.Eval(t,i)},e._HandleParenthesisContent=function(t,i){i=i||function(e){return"true"===e};var r,n=t.split("||");for(var o in n)if(n.hasOwnProperty(o)){var s=e._SimplifyNegation(n[o].trim()),a=s.split("&&");if(a.length>1)for(var l=0;lo.data?(n.mustUpdateRessources=!0,r()):i(o.data):(n.mustUpdateRessources=!0,r())},s.onabort=function(e){i(-1)};var a=s.objectStore("versions").get(t);a.onsuccess=function(e){o=e.target.result},a.onerror=function(r){e.Tools.Error("Error loading version for scene "+t+" from DB."),i(-1)}}catch(t){e.Tools.Error("Error while accessing 'versions' object store (READ OP). Exception: "+t.message),i(-1)}}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i(-1)},t.prototype._saveVersionIntoDBAsync=function(t,i){var r=this;if(this.isSupported&&!this.hasReachedQuota&&this.db)try{var n=this.db.transaction(["versions"],"readwrite");n.onabort=function(e){try{var t=e.srcElement.error;t&&"QuotaExceededError"===t.name&&(r.hasReachedQuota=!0)}catch(e){}i(-1)},n.oncomplete=function(e){i(r.manifestVersionFound)};var o={sceneUrl:t,data:this.manifestVersionFound},s=n.objectStore("versions").put(o);s.onsuccess=function(e){},s.onerror=function(t){e.Tools.Error("Error in DB add version request in BABYLON.Database.")}}catch(t){e.Tools.Error("Error while accessing 'versions' object store (WRITE OP). Exception: "+t.message),i(-1)}else i(-1)},t.prototype.loadFileFromDB=function(e,i,r,n,o){var s=this,a=t.ReturnFullUrlLocation(e),l=function(){s._saveFileIntoDBAsync(a,i,r)};this._checkVersionFromDB(a,(function(e){-1!==e?s.mustUpdateRessources?s._saveFileIntoDBAsync(a,i,r,o):s._loadFileFromDBAsync(a,i,l,o):n&&n()}))},t.prototype._loadFileFromDBAsync=function(t,i,r,n){if(this.isSupported&&this.db){var o;o=-1!==t.indexOf(".babylon")?"scenes":"textures";var s,a=this.db.transaction([o]);a.oncomplete=function(e){s?i(s.data):r()},a.onabort=function(e){r()};var l=a.objectStore(o).get(t);l.onsuccess=function(e){s=e.target.result},l.onerror=function(i){e.Tools.Error("Error loading file "+t+" from DB."),r()}}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i()},t.prototype._saveFileIntoDBAsync=function(t,i,r,n){var o=this;if(this.isSupported){var s;s=-1!==t.indexOf(".babylon")?"scenes":"textures";var a,l=new XMLHttpRequest;l.open("GET",t,!0),n&&(l.responseType="arraybuffer"),r&&(l.onprogress=r),l.addEventListener("load",(function(){if(200===l.status||e.Tools.ValidateXHRData(l,n?6:1))if(a=n?l.response:l.responseText,!o.hasReachedQuota&&o.db){var r=o.db.transaction([s],"readwrite");r.onabort=function(e){try{var t=e.srcElement.error;t&&"QuotaExceededError"===t.name&&(o.hasReachedQuota=!0)}catch(e){}i(a)},r.oncomplete=function(e){i(a)};var h;h="scenes"===s?{sceneUrl:t,data:a,version:o.manifestVersionFound}:{textureUrl:t,data:a};try{var u=r.objectStore(s).put(h);u.onsuccess=function(e){},u.onerror=function(t){e.Tools.Error("Error in DB add file request in BABYLON.Database.")}}catch(e){i(a)}}else i(a);else i()}),!1),l.addEventListener("error",(function(t){e.Tools.Error("error on XHR request."),i()}),!1),l.send()}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i()},t.IsUASupportingBlobStorage=!0,t.IDBStorageEnabled=!0,t.parseURL=function(e){document.createElement("a").href=e;var t=e.substring(0,e.lastIndexOf("#")),i=e.substring(t.lastIndexOf("/")+1,e.length);return e.substring(0,e.indexOf(i,0))},t.ReturnFullUrlLocation=function(e){return-1===e.indexOf("http:/")&&-1===e.indexOf("https:/")?t.parseURL(window.location.href)+e:e},t})();e.Database=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._isEnabled=!0,this.leftColor=e.Color3.White(),this.rightColor=e.Color3.Black(),this.bias=0,this.power=1}return Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(t){this._isEnabled!==t&&(this._isEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.FresnelDirtyFlag))},enumerable:!0,configurable:!0}),t.prototype.clone=function(){var i=new t;return e.Tools.DeepCopy(this,i),i},t.prototype.serialize=function(){var e={};return e.isEnabled=this.isEnabled,e.leftColor=this.leftColor,e.rightColor=this.rightColor,e.bias=this.bias,e.power=this.power,e},t.Parse=function(i){var r=new t;return r.isEnabled=i.isEnabled,r.leftColor=e.Color3.FromArray(i.leftColor),r.rightColor=e.Color3.FromArray(i.rightColor),r.bias=i.bias,r.power=i.power||1,r},t})();e.FresnelParameters=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i){var r=t.call(this,e,i,!0)||this;return i.multiMaterials.push(r),r.subMaterials=new Array,r.storeEffectOnSubMeshes=!0,r}return __extends(i,t),Object.defineProperty(i.prototype,"subMaterials",{get:function(){return this._subMaterials},set:function(e){this._subMaterials=e,this._hookArray(e)},enumerable:!0,configurable:!0}),i.prototype._hookArray=function(e){var t=this,i=e.push;e.push=function(){for(var r=[],n=0;n=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},i.prototype.getActiveTextures=function(){return(e=t.prototype.getActiveTextures.call(this)).concat.apply(e,this.subMaterials.map((function(e){return e?e.getActiveTextures():[]})));var e},i.prototype.getClassName=function(){return"MultiMaterial"},i.prototype.isReadyForSubMesh=function(e,t,i){for(var r=0;r=0&&r.multiMaterials.splice(n,1),t.prototype.dispose.call(this,e,i)}},i})(e.Material);e.MultiMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._offsetX=null,this._offsetY=null,this._pointerCount=0,this._pointerPressed=new Array,this.touchAngularSensibility=2e5,this.touchMoveSensibility=250}return t.prototype.attachControl=function(t,i){var r=this,n=null;void 0===this._pointerInput&&(this._onLostFocus=function(e){r._offsetX=null,r._offsetY=null},this._pointerInput=function(t,o){var s=t.event;if("mouse"!==s.pointerType)if(t.type===e.PointerEventTypes.POINTERDOWN){if(i||s.preventDefault(),r._pointerPressed.push(s.pointerId),1!==r._pointerPressed.length)return;n={x:s.clientX,y:s.clientY}}else if(t.type===e.PointerEventTypes.POINTERUP){i||s.preventDefault();var a=r._pointerPressed.indexOf(s.pointerId);if(-1===a)return;if(r._pointerPressed.splice(a,1),0!=a)return;n=null,r._offsetX=null,r._offsetY=null}else if(t.type===e.PointerEventTypes.POINTERMOVE){if(i||s.preventDefault(),!n)return;var a=r._pointerPressed.indexOf(s.pointerId);if(0!=a)return;r._offsetX=s.clientX-n.x,r._offsetY=-(s.clientY-n.y)}}),this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,e.PointerEventTypes.POINTERDOWN|e.PointerEventTypes.POINTERUP|e.PointerEventTypes.POINTERMOVE),this._onLostFocus&&t.addEventListener("blur",this._onLostFocus)},t.prototype.detachControl=function(e){this._pointerInput&&e&&(this._observer&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null),this._onLostFocus&&(e.removeEventListener("blur",this._onLostFocus),this._onLostFocus=null),this._pointerPressed=[],this._offsetX=null,this._offsetY=null,this._pointerCount=0)},t.prototype.checkInputs=function(){if(this._offsetX&&this._offsetY){var t=this.camera;if(t.cameraRotation.y+=this._offsetX/this.touchAngularSensibility,this._pointerPressed.length>1)t.cameraRotation.x+=-this._offsetY/this.touchAngularSensibility;else{var i=t._computeLocalCameraSpeed(),r=new e.Vector3(0,0,i*this._offsetY/this.touchMoveSensibility);e.Matrix.RotationYawPitchRollToRef(t.rotation.y,t.rotation.x,0,t._cameraRotationMatrix),t.cameraDirection.addInPlace(e.Vector3.TransformCoordinates(r,t._cameraRotationMatrix))}}},t.prototype.getClassName=function(){return"FreeCameraTouchInput"},t.prototype.getSimpleName=function(){return"touch"},__decorate([e.serialize()],t.prototype,"touchAngularSensibility",void 0),__decorate([e.serialize()],t.prototype,"touchMoveSensibility",void 0),t})();e.FreeCameraTouchInput=t,e.CameraInputTypes.FreeCameraTouchInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addTouch(),n._setupInputs(),n}return __extends(t,e),Object.defineProperty(t.prototype,"touchAngularSensibility",{get:function(){var e=this.inputs.attached.touch;return e?e.touchAngularSensibility:0},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchAngularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"touchMoveSensibility",{get:function(){var e=this.inputs.attached.touch;return e?e.touchMoveSensibility:0},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"TouchCamera"},t.prototype._setupInputs=function(){var e=this.inputs.attached.mouse;e&&(e.touchEnabled=!1)},t})(e.FreeCamera);e.TouchCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a,l){void 0===s&&(s=null),void 0===a&&(a=!0),void 0===l&&(l=!1);var h=t.call(this,null,o,!a)||this;h.isCube=l,h.isEnabled=!0,h._currentRefreshId=-1,h._refreshRate=1,h._vertexBuffers={},h._uniforms=new Array,h._samplers=new Array,h._textures={},h._floats={},h._floatsArrays={},h._colors3={},h._colors4={},h._vectors2={},h._vectors3={},h._matrices={},h._fallbackTextureUsed=!1,o._proceduralTextures.push(h),h._engine=o.getEngine(),h.name=i,h.isRenderTarget=!0,h._size=r,h._generateMipMaps=a,h.setFragment(n),h._fallbackTexture=s,l?(h._texture=h._engine.createRenderTargetCubeTexture(r,{generateMipMaps:a}),h.setFloat("face",0)):h._texture=h._engine.createRenderTargetTexture(r,a);var u=[];return u.push(1,1),u.push(-1,1),u.push(-1,-1),u.push(1,-1),h._vertexBuffers[e.VertexBuffer.PositionKind]=new e.VertexBuffer(h._engine,u,e.VertexBuffer.PositionKind,!1,!1,2),h._createIndexBuffer(),h}return __extends(i,t),i.prototype._createIndexBuffer=function(){var e=this._engine,t=[];t.push(0),t.push(1),t.push(2),t.push(0),t.push(2),t.push(3),this._indexBuffer=e.createIndexBuffer(t)},i.prototype._rebuild=function(){var t=this._vertexBuffers[e.VertexBuffer.PositionKind];t&&t._rebuild(),this._createIndexBuffer(),this.refreshRate===e.RenderTargetTexture.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=e.RenderTargetTexture.REFRESHRATE_RENDER_ONCE)},i.prototype.reset=function(){if(void 0!==this._effect){this._engine._releaseEffect(this._effect)}},i.prototype.isReady=function(){var t,i=this,r=this._engine;return!!this._fragment&&(!!this._fallbackTextureUsed||(t=void 0!==this._fragment.fragmentElement?{vertex:"procedural",fragmentElement:this._fragment.fragmentElement}:{vertex:"procedural",fragment:this._fragment},this._effect=r.createEffect(t,[e.VertexBuffer.PositionKind],this._uniforms,this._samplers,"",void 0,void 0,(function(){i.releaseInternalTexture(), i._fallbackTexture&&(i._texture=i._fallbackTexture._texture,i._texture&&i._texture.incrementReferences()),i._fallbackTextureUsed=!0})),this._effect.isReady()))},i.prototype.resetRefreshCounter=function(){this._currentRefreshId=-1},i.prototype.setFragment=function(e){this._fragment=e},Object.defineProperty(i.prototype,"refreshRate",{get:function(){return this._refreshRate},set:function(e){this._refreshRate=e,this.resetRefreshCounter()},enumerable:!0,configurable:!0}),i.prototype._shouldRender=function(){return!!(this.isEnabled&&this.isReady()&&this._texture)&&(!this._fallbackTextureUsed&&(-1===this._currentRefreshId?(this._currentRefreshId=1,!0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)))},i.prototype.getRenderSize=function(){return this._size},i.prototype.resize=function(e,t){this._fallbackTextureUsed||(this.releaseInternalTexture(),this._texture=this._engine.createRenderTargetTexture(e,t))},i.prototype._checkUniform=function(e){-1===this._uniforms.indexOf(e)&&this._uniforms.push(e)},i.prototype.setTexture=function(e,t){return-1===this._samplers.indexOf(e)&&this._samplers.push(e),this._textures[e]=t,this},i.prototype.setFloat=function(e,t){return this._checkUniform(e),this._floats[e]=t,this},i.prototype.setFloats=function(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this},i.prototype.setColor3=function(e,t){return this._checkUniform(e),this._colors3[e]=t,this},i.prototype.setColor4=function(e,t){return this._checkUniform(e),this._colors4[e]=t,this},i.prototype.setVector2=function(e,t){return this._checkUniform(e),this._vectors2[e]=t,this},i.prototype.setVector3=function(e,t){return this._checkUniform(e),this._vectors3[e]=t,this},i.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},i.prototype.render=function(e){var t=this.getScene();if(t){var i=this._engine;i.enableEffect(this._effect),i.setState(!1);for(var r in this._textures)this._effect.setTexture(r,this._textures[r]);for(r in this._floats)this._effect.setFloat(r,this._floats[r]);for(r in this._floatsArrays)this._effect.setArray(r,this._floatsArrays[r]);for(r in this._colors3)this._effect.setColor3(r,this._colors3[r]);for(r in this._colors4){var n=this._colors4[r];this._effect.setFloat4(r,n.r,n.g,n.b,n.a)}for(r in this._vectors2)this._effect.setVector2(r,this._vectors2[r]);for(r in this._vectors3)this._effect.setVector3(r,this._vectors3[r]);for(r in this._matrices)this._effect.setMatrix(r,this._matrices[r]);if(this._texture){if(this.isCube)for(var o=0;o<6;o++)i.bindFramebuffer(this._texture,o,void 0,void 0,!0),i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect),this._effect.setFloat("face",o),i.clear(t.clearColor,!0,!0,!0),i.draw(!0,0,6),5===o&&i.generateMipMapsForCubemap(this._texture);else i.bindFramebuffer(this._texture,0,void 0,void 0,!0),i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect),i.clear(t.clearColor,!0,!0,!0),i.draw(!0,0,6);i.unBindFramebuffer(this._texture,this.isCube),this.onGenerated&&this.onGenerated()}}},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this._fragment,this.getScene(),this._fallbackTexture,this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.coordinatesMode=this.coordinatesMode,t},i.prototype.dispose=function(){var i=this.getScene();if(i){var r=i._proceduralTextures.indexOf(this);r>=0&&i._proceduralTextures.splice(r,1);var n=this._vertexBuffers[e.VertexBuffer.PositionKind];n&&(n.dispose(),this._vertexBuffers[e.VertexBuffer.PositionKind]=null),this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer)&&(this._indexBuffer=null),t.prototype.dispose.call(this)}},i})(e.Texture);e.ProceduralTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i,r,n,o,s){var a=t.call(this,e,r,null,n,o,s)||this;return a._animate=!0,a._time=0,a._texturePath=i,a.loadJson(i),a.refreshRate=1,a}return __extends(i,t),i.prototype.loadJson=function(t){var i=this,r=function(){e.Tools.Log("No config file found in "+t+" trying to use ShadersStore or DOM element");try{i.setFragment(i._texturePath)}catch(t){e.Tools.Error("No json or ShaderStore or DOM element found for CustomProceduralTexture")}},n=t+"/config.json",o=new XMLHttpRequest;o.open("GET",n,!0),o.addEventListener("load",(function(){if(200===o.status||e.Tools.ValidateXHRData(o,1))try{i._config=JSON.parse(o.response),i.updateShaderUniforms(),i.updateTextures(),i.setFragment(i._texturePath+"/custom"),i._animate=i._config.animate,i.refreshRate=i._config.refreshrate}catch(e){r()}else r()}),!1),o.addEventListener("error",(function(){r()}),!1);try{o.send()}catch(t){e.Tools.Error("CustomProceduralTexture: Error on XHR send request.")}},i.prototype.isReady=function(){if(!t.prototype.isReady.call(this))return!1;for(var e in this._textures){if(!this._textures[e].isReady())return!1}return!0},i.prototype.render=function(e){var i=this.getScene();this._animate&&i&&(this._time+=.03*i.getAnimationRatio(),this.updateShaderUniforms()),t.prototype.render.call(this,e)},i.prototype.updateTextures=function(){for(var t=0;t.005?0+r:0,i.y=Math.abs(n)>.005?0+n:0;var o=this.gamepad.rightStick;if(o){var s=o.x/this.gamepadAngularSensibility,a=o.y/this.gamepadAngularSensibility;o.x=Math.abs(s)>.001?0+s:0,o.y=Math.abs(a)>.001?0+a:0}else o={x:0,y:0};t.rotationQuaternion?t.rotationQuaternion.toRotationMatrix(this._cameraTransform):e.Matrix.RotationYawPitchRollToRef(t.rotation.y,t.rotation.x,0,this._cameraTransform);var l=50*t._computeLocalCameraSpeed();this._vector3.copyFromFloats(i.x*l,0,-i.y*l),e.Vector3.TransformCoordinatesToRef(this._vector3,this._cameraTransform,this._deltaTransform),t.cameraDirection.addInPlace(this._deltaTransform),this._vector2.copyFromFloats(o.y,o.x),t.cameraRotation.addInPlace(this._vector2)}},t.prototype.getClassName=function(){return"FreeCameraGamepadInput"},t.prototype.getSimpleName=function(){return"gamepad"},__decorate([e.serialize()],t.prototype,"gamepadAngularSensibility",void 0),__decorate([e.serialize()],t.prototype,"gamepadMoveSensibility",void 0),t})();e.FreeCameraGamepadInput=t,e.CameraInputTypes.FreeCameraGamepadInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this.gamepadRotationSensibility=80,this.gamepadMoveSensibility=40}return t.prototype.attachControl=function(t,i){var r=this,n=this.camera.getScene().gamepadManager;this._onGamepadConnectedObserver=n.onGamepadConnectedObservable.add((function(t){t.type!==e.Gamepad.POSE_ENABLED&&(r.gamepad&&t.type!==e.Gamepad.XBOX||(r.gamepad=t))})),this._onGamepadDisconnectedObserver=n.onGamepadDisconnectedObservable.add((function(e){r.gamepad===e&&(r.gamepad=null)})),this.gamepad=n.getGamepadByType(e.Gamepad.XBOX)},t.prototype.detachControl=function(e){this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),this.gamepad=null},t.prototype.checkInputs=function(){if(this.gamepad){var e=this.camera,t=this.gamepad.rightStick;if(t){if(0!=t.x){var i=t.x/this.gamepadRotationSensibility;0!=i&&Math.abs(i)>.005&&(e.inertialAlphaOffset+=i)}if(0!=t.y){var r=t.y/this.gamepadRotationSensibility;0!=r&&Math.abs(r)>.005&&(e.inertialBetaOffset+=r)}}var n=this.gamepad.leftStick;if(n&&0!=n.y){var o=n.y/this.gamepadMoveSensibility;0!=o&&Math.abs(o)>.005&&(this.camera.inertialRadiusOffset-=o)}}},t.prototype.getClassName=function(){return"ArcRotateCameraGamepadInput"},t.prototype.getSimpleName=function(){return"gamepad"},__decorate([e.serialize()],t.prototype,"gamepadRotationSensibility",void 0),__decorate([e.serialize()],t.prototype,"gamepadMoveSensibility",void 0),t})();e.ArcRotateCameraGamepadInput=t,e.CameraInputTypes.ArcRotateCameraGamepadInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){var t=this;this._babylonGamepads=[],this._oneGamepadConnected=!1,this._isMonitoring=!1,this.onGamepadDisconnectedObservable=new e.Observable,e.Tools.IsWindowObjectExist()?(this._gamepadEventSupported="GamepadEvent"in window,this._gamepadSupport=navigator.getGamepads||navigator.webkitGetGamepads||navigator.msGetGamepads||navigator.webkitGamepads):this._gamepadEventSupported=!1,this.onGamepadConnectedObservable=new e.Observable(function(e){for(var i in t._babylonGamepads){var r=t._babylonGamepads[i];r&&r._isConnected&&t.onGamepadConnectedObservable.notifyObserver(e,r)}}),this._onGamepadConnectedEvent=function(e){var i=e.gamepad;if(!(i.index in t._babylonGamepads&&t._babylonGamepads[i.index].isConnected)){var r;t._babylonGamepads[i.index]?(r=t._babylonGamepads[i.index],r.browserGamepad=i,r._isConnected=!0):r=t._addNewGamepad(i),t.onGamepadConnectedObservable.notifyObservers(r),t._startMonitoringGamepads()}},this._onGamepadDisconnectedEvent=function(e){var i=e.gamepad;for(var r in t._babylonGamepads)if(t._babylonGamepads[r].index===i.index){var n=t._babylonGamepads[r];n._isConnected=!1,t.onGamepadDisconnectedObservable.notifyObservers(n);break}},this._gamepadSupport&&(this._updateGamepadObjects(),this._babylonGamepads.length&&this._startMonitoringGamepads(),this._gamepadEventSupported?(window.addEventListener("gamepadconnected",this._onGamepadConnectedEvent,!1),window.addEventListener("gamepaddisconnected",this._onGamepadDisconnectedEvent,!1)):this._startMonitoringGamepads())}return Object.defineProperty(t.prototype,"gamepads",{get:function(){return this._babylonGamepads},enumerable:!0,configurable:!0}),t.prototype.getGamepadByType=function(t){void 0===t&&(t=e.Gamepad.XBOX);for(var i=0,r=this._babylonGamepads;i=2&&(this._leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),this.browserGamepad.axes.length>=4&&(this._rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})}return Object.defineProperty(e.prototype,"isConnected",{get:function(){return this._isConnected},enumerable:!0,configurable:!0}),e.prototype.onleftstickchanged=function(e){this._onleftstickchanged=e},e.prototype.onrightstickchanged=function(e){this._onrightstickchanged=e},Object.defineProperty(e.prototype,"leftStick",{get:function(){return this._leftStick},set:function(e){!this._onleftstickchanged||this._leftStick.x===e.x&&this._leftStick.y===e.y||this._onleftstickchanged(e),this._leftStick=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightStick",{get:function(){return this._rightStick},set:function(e){!this._onrightstickchanged||this._rightStick.x===e.x&&this._rightStick.y===e.y||this._onrightstickchanged(e),this._rightStick=e},enumerable:!0,configurable:!0}),e.prototype.update=function(){this._leftStick&&(this.leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),this._rightStick&&(this.rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})},e.prototype.dispose=function(){},e.GAMEPAD=0,e.GENERIC=1,e.XBOX=2,e.POSE_ENABLED=3,e})();e.Gamepad=i;var r=(function(t){function r(r,n,o){var s=t.call(this,r,n,o)||this;return s.onButtonDownObservable=new e.Observable,s.onButtonUpObservable=new e.Observable,s.type=i.GENERIC,s._buttons=new Array(o.buttons.length),s}return __extends(r,t),r.prototype.onbuttondown=function(e){this._onbuttondown=e},r.prototype.onbuttonup=function(e){this._onbuttonup=e},r.prototype._setButtonValue=function(e,t,i){return e!==t&&(1===e&&(this._onbuttondown&&this._onbuttondown(i),this.onButtonDownObservable.notifyObservers(i)),0===e&&(this._onbuttonup&&this._onbuttonup(i),this.onButtonUpObservable.notifyObservers(i))),e},r.prototype.update=function(){t.prototype.update.call(this);for(var e=0;ethis.maxCameraSpeed||c<-this.maxCameraSpeed)&&(c=c<1?-this.maxCameraSpeed:this.maxCameraSpeed),(f>this.maxCameraSpeed||f<-this.maxCameraSpeed)&&(f=f<1?-this.maxCameraSpeed:this.maxCameraSpeed),(d>this.maxCameraSpeed||d<-this.maxCameraSpeed)&&(d=d<1?-this.maxCameraSpeed:this.maxCameraSpeed),this.position=new e.Vector3(this.position.x+c,this.position.y+f,this.position.z+d),this.setTarget(o)}},i.prototype._checkInputs=function(){t.prototype._checkInputs.call(this),this.lockedTarget&&this.follow(this.lockedTarget)},i.prototype.getClassName=function(){return"FollowCamera"},__decorate([e.serialize()],i.prototype,"radius",void 0),__decorate([e.serialize()],i.prototype,"rotationOffset",void 0),__decorate([e.serialize()],i.prototype,"heightOffset",void 0),__decorate([e.serialize()],i.prototype,"cameraAcceleration",void 0),__decorate([e.serialize()],i.prototype,"maxCameraSpeed",void 0),__decorate([e.serializeAsMeshReference("lockedTargetId")],i.prototype,"lockedTarget",void 0),i})(e.TargetCamera);e.FollowCamera=t;var i=(function(t){function i(i,r,n,o,s,a){var l=t.call(this,i,e.Vector3.Zero(),a)||this;return l.alpha=r,l.beta=n,l.radius=o,l.target=s,l._cartesianCoordinates=e.Vector3.Zero(),l.follow(),l}return __extends(i,t),i.prototype.follow=function(){if(this.target){this._cartesianCoordinates.x=this.radius*Math.cos(this.alpha)*Math.cos(this.beta),this._cartesianCoordinates.y=this.radius*Math.sin(this.beta),this._cartesianCoordinates.z=this.radius*Math.sin(this.alpha)*Math.cos(this.beta);var e=this.target.getAbsolutePosition();this.position=e.add(this._cartesianCoordinates),this.setTarget(e)}},i.prototype._checkInputs=function(){t.prototype._checkInputs.call(this),this.follow()},i.prototype.getClassName=function(){return"ArcFollowCamera"},i})(e.TargetCamera);e.ArcFollowCamera=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addGamepad(),n}return __extends(t,e),Object.defineProperty(t.prototype,"gamepadAngularSensibility",{get:function(){var e=this.inputs.attached.gamepad;return e?e.gamepadAngularSensibility:0},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadAngularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"gamepadMoveSensibility",{get:function(){var e=this.inputs.attached.gamepad;return e?e.gamepadMoveSensibility:0},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"UniversalCamera"},t})(e.TouchCamera);e.UniversalCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){return e.call(this,t,i,r)||this}return __extends(t,e),Object.defineProperty(t.prototype,"gamepadAngularSensibility",{get:function(){var e=this.inputs.attached.gamepad;return e?e.gamepadAngularSensibility:0},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadAngularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"gamepadMoveSensibility",{get:function(){var e=this.inputs.attached.gamepad;return e?e.gamepadMoveSensibility:0},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"GamepadCamera"},t})(e.UniversalCamera);e.GamepadCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this._renderPipelines={}}return e.prototype.addPipeline=function(e){this._renderPipelines[e._name]=e},e.prototype.attachCamerasToRenderPipeline=function(e,t,i){void 0===i&&(i=!1);var r=this._renderPipelines[e];r&&r._attachCameras(t,i)},e.prototype.detachCamerasFromRenderPipeline=function(e,t){var i=this._renderPipelines[e];i&&i._detachCameras(t)},e.prototype.enableEffectInPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._enableEffect(t,i)},e.prototype.disableEffectInPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._disableEffect(t,i)},e.prototype.enableDisplayOnlyPassInPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._enableDisplayOnlyPass(t,i)},e.prototype.disableDisplayOnlyPassInPipeline=function(e,t){var i=this._renderPipelines[e];i&&i._disableDisplayOnlyPass(t)},e.prototype.update=function(){for(var e in this._renderPipelines)if(this._renderPipelines.hasOwnProperty(e)){var t=this._renderPipelines[e];t.isSupported?t._update():(t.dispose(),delete this._renderPipelines[e])}},e.prototype._rebuild=function(){for(var e in this._renderPipelines)if(this._renderPipelines.hasOwnProperty(e)){var t=this._renderPipelines[e];t._rebuild()}},e.prototype.dispose=function(){for(var e in this._renderPipelines)if(this._renderPipelines.hasOwnProperty(e)){var t=this._renderPipelines[e];t.dispose()}},e})();e.PostProcessRenderPipelineManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r,n,o,s){this._refCount=0,this._name=i,this._renderTexture=new e.RenderTargetTexture(i,r,t),this.setRenderList(n),this._renderTexture.onBeforeRenderObservable.add(o),this._renderTexture.onAfterRenderObservable.add(s),this._scene=t,this._renderList=n}return t.prototype._incRefCount=function(){return 0===this._refCount&&this._scene.customRenderTargets.push(this._renderTexture),++this._refCount},t.prototype._decRefCount=function(){return this._refCount--,this._refCount<=0&&this._scene.customRenderTargets.splice(this._scene.customRenderTargets.indexOf(this._renderTexture),1),this._refCount},t.prototype._update=function(){this.setRenderList(this._renderList)},t.prototype.setRenderList=function(e){this._renderTexture.renderList=e},t.prototype.getRenderTexture=function(){return this._renderTexture},t})();e.PostProcessRenderPass=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t,i,r){this._engine=e,this._name=t,this._singleInstance=r||!0,this._getPostProcess=i,this._cameras={},this._indicesForCamera={},this._postProcesses={},this._renderPasses={},this._renderEffectAsPasses={}}return Object.defineProperty(t.prototype,"isSupported",{get:function(){for(var e in this._postProcesses)if(!this._postProcesses[e].isSupported)return!1;return!0},enumerable:!0,configurable:!0}),t.prototype._update=function(){for(var e in this._renderPasses)this._renderPasses[e]._update()},t.prototype.addPass=function(e){this._renderPasses[e._name]=e,this._linkParameters()},t.prototype.removePass=function(e){delete this._renderPasses[e._name],this._linkParameters()},t.prototype.addRenderEffectAsPass=function(e){this._renderEffectAsPasses[e._name]=e,this._linkParameters()},t.prototype.getPass=function(e){for(var t in this._renderPasses)if(t===e)return this._renderPasses[e];return null},t.prototype.emptyPasses=function(){this._renderPasses={},this._linkParameters()},t.prototype._attachCameras=function(t){var i,r=e.Tools.MakeArray(t||this._cameras);if(r){for(var n=0;n4&&(o.push(e.VertexBuffer.MatricesIndicesExtraKind),o.push(e.VertexBuffer.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+s.numBoneInfluencers),n.push("#define BonesPerMesh "+(s.skeleton?s.skeleton.bones.length+1:0))):n.push("#define NUM_BONE_INFLUENCERS 0"),i&&(n.push("#define INSTANCES"),o.push("world0"),o.push("world1"),o.push("world2"),o.push("world3"));var a=n.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this._scene.getEngine().createEffect("depth",o,["world","mBones","viewProjection","diffuseMatrix","depthValues"],["diffuseSampler"],a)),this._effect.isReady()},t.prototype.getDepthMap=function(){return this._depthMap},t.prototype.dispose=function(){this._depthMap.dispose()},t})();e.DepthRenderer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o){var s=t.call(this,r.getEngine(),i)||this;s.SSAOOriginalSceneColorEffect="SSAOOriginalSceneColorEffect",s.SSAORenderEffect="SSAORenderEffect",s.SSAOBlurHRenderEffect="SSAOBlurHRenderEffect",s.SSAOBlurVRenderEffect="SSAOBlurVRenderEffect",s.SSAOCombineRenderEffect="SSAOCombineRenderEffect",s.totalStrength=1,s.radius=1e-4,s.area=.0075,s.fallOff=1e-6,s.base=.5,s._firstUpdate=!0,s._scene=r,s._createRandomTexture(),s._depthTexture=r.enableDepthRenderer().getDepthMap();var a=n.ssaoRatio||n,l=n.combineRatio||n;return s._ratio={ssaoRatio:a,combineRatio:l},s._originalColorPostProcess=new e.PassPostProcess("SSAOOriginalSceneColor",l,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),!1),s._createSSAOPostProcess(a),s._createBlurPostProcess(a),s._createSSAOCombinePostProcess(l),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOOriginalSceneColorEffect,function(){return s._originalColorPostProcess},!0)),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAORenderEffect,function(){return s._ssaoPostProcess},!0)),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOBlurHRenderEffect,function(){return s._blurHPostProcess},!0)),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOBlurVRenderEffect,function(){return s._blurVPostProcess},!0)),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOCombineRenderEffect,function(){return s._ssaoCombinePostProcess},!0)),r.postProcessRenderPipelineManager.addPipeline(s),o&&r.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(i,o),s}return __extends(i,t),i.prototype.dispose=function(e){void 0===e&&(e=!1);for(var i=0;i0?r._ssaoCombinePostProcess.width:r._originalColorPostProcess.width),e.setFloat("near",r._scene.activeCamera.minZ),e.setFloat("far",r._scene.activeCamera.maxZ),e.setFloat("radius",r.radius),e.setTexture("depthSampler",r._depthTexture),r._firstUpdate&&e.setArray("samplerOffsets",r._samplerOffsets))},this._blurVPostProcess=new e.PostProcess("BlurV","ssao2",["outSize","samplerOffsets","near","far","radius"],["depthSampler"],i,null,e.Texture.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define BILATERAL_BLUR\n#define BILATERAL_BLUR_V\n#define SAMPLES 16\n#define EXPENSIVE "+(n?"1":"0")+"\n"),this._blurVPostProcess.onApply=function(e){r._scene.activeCamera&&(e.setFloat("outSize",r._ssaoCombinePostProcess.height>0?r._ssaoCombinePostProcess.height:r._originalColorPostProcess.height),e.setFloat("near",r._scene.activeCamera.minZ),e.setFloat("far",r._scene.activeCamera.maxZ),e.setFloat("radius",r.radius),e.setTexture("depthSampler",r._depthTexture),r._firstUpdate&&(e.setArray("samplerOffsets",r._samplerOffsets),r._firstUpdate=!1))}},i.prototype._rebuild=function(){this._firstUpdate=!0,t.prototype._rebuild.call(this)},i.prototype._generateHemisphere=function(){for(var t,i,r=this.samples,n=[],o=function(e,t){return Math.random()*(t-e)+e},s=0;s=0;a--){var o=Math.pow(3,a),l="#define LUMINANCE_DOWN_SAMPLE\n";0===a&&(l+="#define FINAL_DOWN_SAMPLER");var h=new e.PostProcess("HDRLuminanceDownSample"+a,"standard",["dsOffsets","halfDestPixelSize"],[],{width:o,height:o},null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,l,r);this.luminanceDownSamplePostProcesses.push(h)}var u=this.luminancePostProcess;this.luminanceDownSamplePostProcesses.forEach((function(i,r){var o=new Array(18);i.onApply=function(e){if(u){for(var t=0,s=-1;s<2;s++)for(var a=-1;a<2;a++)o[t]=s/u.width,o[t+1]=a/u.height,t+=2;e.setArray2("dsOffsets",o),e.setFloat("halfDestPixelSize",.5/u.width),u=r===n.luminanceDownSamplePostProcesses.length-1?n.luminancePostProcess:i}},r===n.luminanceDownSamplePostProcesses.length-1&&(i.onAfterRender=function(i){var r=t.getEngine().readPixels(0,0,1,1),o=new e.Vector4(1/16581375,1/65025,1/255,1);n._hdrCurrentLuminance=(r[0]*o.x+r[1]*o.y+r[2]*o.z+r[3]*o.w)/100}),n.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRLuminanceDownSample"+r,function(){return i},!0))}))},i.prototype._createHdrPostProcess=function(t,i){var r=this;this.hdrPostProcess=new e.PostProcess("HDR","standard",["averageLuminance"],["textureAdderSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define HDR",e.Engine.TEXTURETYPE_UNSIGNED_INT);var n=1,o=0,s=0;this.hdrPostProcess.onApply=function(i){if(i.setTextureFromPostProcess("textureAdderSampler",r._currentDepthOfFieldSource),o+=t.getEngine().getDeltaTime(),n<0)n=r._hdrCurrentLuminance;else{var a=(s-o)/1e3;r._hdrCurrentLuminancen-r.hdrIncreaseRate*a?n-=r.hdrIncreaseRate*a:n=r._hdrCurrentLuminance}n=e.Scalar.Clamp(n,r.hdrMinimumLuminance,1e20),i.setFloat("averageLuminance",n),s=o,r._currentDepthOfFieldSource=r.hdrFinalPostProcess},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDR",function(){return r.hdrPostProcess},!0))},i.prototype._createLensFlarePostProcess=function(t,i){var r=this;this.lensFlarePostProcess=new e.PostProcess("HDRLensFlare","standard",["strength","ghostDispersal","haloWidth","resolution","distortionStrength"],["lensColorSampler"],i/2,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define LENS_FLARE",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRLensFlare",function(){return r.lensFlarePostProcess},!0)),this._createBlurPostProcesses(t,i/4,2),this.lensFlareComposePostProcess=new e.PostProcess("HDRLensFlareCompose","standard",["lensStarMatrix"],["otherSampler","lensDirtSampler","lensStarSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define LENS_FLARE_COMPOSE",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRLensFlareCompose",function(){return r.lensFlareComposePostProcess},!0));var n=new e.Vector2(0,0);this.lensFlarePostProcess.onApply=function(e){e.setTextureFromPostProcess("textureSampler",r._bloomEnabled?r.blurHPostProcesses[0]:r.originalPostProcess),e.setTexture("lensColorSampler",r.lensColorTexture),e.setFloat("strength",r.lensFlareStrength),e.setFloat("ghostDispersal",r.lensFlareGhostDispersal),e.setFloat("haloWidth",r.lensFlareHaloWidth),n.x=r.lensFlarePostProcess.width,n.y=r.lensFlarePostProcess.height,e.setVector2("resolution",n),e.setFloat("distortionStrength",r.lensFlareDistortionStrength)};var o=e.Matrix.FromValues(2,0,-1,0,0,2,-1,0,0,0,1,0,0,0,0,1),s=e.Matrix.FromValues(.5,0,.5,0,0,.5,.5,0,0,0,1,0,0,0,0,1);this.lensFlareComposePostProcess.onApply=function(t){if(r._scene.activeCamera){t.setTextureFromPostProcess("otherSampler",r._currentDepthOfFieldSource),t.setTexture("lensDirtSampler",r.lensFlareDirtTexture),t.setTexture("lensStarSampler",r.lensStarTexture);var i=r._scene.activeCamera.getViewMatrix().getRow(0),n=r._scene.activeCamera.getViewMatrix().getRow(2),a=e.Vector3.Dot(i.toVector3(),new e.Vector3(1,0,0))+e.Vector3.Dot(n.toVector3(),new e.Vector3(0,0,1));a*=4;var l=e.Matrix.FromValues(.5*Math.cos(a),-Math.sin(a),0,0,Math.sin(a),.5*Math.cos(a),0,0,0,0,1,0,0,0,0,1),h=s.multiply(l).multiply(o);t.setMatrix("lensStarMatrix",h),r._currentDepthOfFieldSource=r.lensFlareFinalPostProcess}}},i.prototype._createDepthOfFieldPostProcess=function(t,i){var r=this;this.depthOfFieldPostProcess=new e.PostProcess("HDRDepthOfField","standard",["distance"],["otherSampler","depthSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define DEPTH_OF_FIELD",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.depthOfFieldPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",r._currentDepthOfFieldSource),e.setTexture("depthSampler",r._getDepthTexture()),e.setFloat("distance",r.depthOfFieldDistance)},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRDepthOfField",function(){return r.depthOfFieldPostProcess},!0))},i.prototype._createMotionBlurPostProcess=function(t,i){var r=this;this.motionBlurPostProcess=new e.PostProcess("HDRMotionBlur","standard",["inverseViewProjection","prevViewProjection","screenSize","motionScale","motionStrength"],["depthSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES "+this.motionBlurSamples.toFixed(1),e.Engine.TEXTURETYPE_UNSIGNED_INT);var n=0,o=e.Matrix.Identity(),s=e.Matrix.Identity(),a=e.Matrix.Identity(),l=e.Vector2.Zero();this.motionBlurPostProcess.onApply=function(e){a=t.getProjectionMatrix().multiply(t.getViewMatrix()),a.invertToRef(s),e.setMatrix("inverseViewProjection",s),e.setMatrix("prevViewProjection",o),o=a,l.x=r.motionBlurPostProcess.width,l.y=r.motionBlurPostProcess.height,e.setVector2("screenSize",l),n=t.getEngine().getFps()/60,e.setFloat("motionScale",n),e.setFloat("motionStrength",r.motionStrength),e.setTexture("depthSampler",r._getDepthTexture())},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRMotionBlur",function(){return r.motionBlurPostProcess},!0))},i.prototype._getDepthTexture=function(){if(this._scene.getEngine().getCaps().drawBuffersExtension){return this._scene.enableGeometryBufferRenderer().getGBuffer().textures[0]}return this._scene.enableDepthRenderer().getDepthMap()},i.prototype._disposePostProcesses=function(){for(var e=0;e4&&(o.push(e.VertexBuffer.MatricesIndicesExtraKind),o.push(e.VertexBuffer.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+s.numBoneInfluencers),n.push("#define BonesPerMesh "+(s.skeleton?s.skeleton.bones.length+1:0))):n.push("#define NUM_BONE_INFLUENCERS 0"),i&&(n.push("#define INSTANCES"),o.push("world0"),o.push("world1"),o.push("world2"),o.push("world3"));var a=n.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this._scene.getEngine().createEffect("geometry",o,["world","mBones","viewProjection","diffuseMatrix","view"],["diffuseSampler"],a,void 0,void 0,void 0,{buffersCount:this._enablePosition?3:2})),this._effect.isReady()},t.prototype.getGBuffer=function(){return this._multiRenderTarget},t.prototype.dispose=function(){this.getGBuffer().dispose()},t.prototype._createRenderTargets=function(){var t=this,i=this._scene.getEngine(),r=this._enablePosition?3:2;if(this._multiRenderTarget=new e.MultiRenderTarget("gBuffer",{width:i.getRenderWidth()*this._ratio,height:i.getRenderHeight()*this._ratio},r,this._scene,{generateMipMaps:!1,generateDepthTexture:!0}),this.isSupported){this._multiRenderTarget.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._multiRenderTarget.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._multiRenderTarget.refreshRate=1,this._multiRenderTarget.renderParticles=!1,this._multiRenderTarget.renderList=null,this._multiRenderTarget.onClearObservable.add((function(t){t.clear(new e.Color4(0,0,0,1),!0,!0,!0)}));var n=function(i){var r=i.getRenderingMesh(),n=t._scene,o=n.getEngine(),s=i.getMaterial();if(s){o.setState(s.backFaceCulling);var a=r._getInstancesRenderList(i._id);if(!a.mustReturn){var l=o.getCaps().instancedArrays&&null!==a.visibleInstances[i._id];if(t.isReady(i,l)){if(o.enableEffect(t._effect),r._bind(i,t._effect,e.Material.TriangleFillMode),t._effect.setMatrix("viewProjection",n.getTransformMatrix()),t._effect.setMatrix("view",n.getViewMatrix()),s&&s.needAlphaTesting()){var h=s.getAlphaTestTexture();h&&(t._effect.setTexture("diffuseSampler",h),t._effect.setMatrix("diffuseMatrix",h.getTextureMatrix()))}r.useBones&&r.computeBonesUsingShaders&&r.skeleton&&t._effect.setMatrices("mBones",r.skeleton.getTransformMatrices(r)),r._processRendering(i,t._effect,e.Material.TriangleFillMode,a,l,(function(e,i){return t._effect.setMatrix("world",i)}))}}}};this._multiRenderTarget.customRenderFunction=function(e,t,r,o){var s;if(o.length){for(i.setColorWrite(!1),s=0;s0&&-1!==this.excludedMeshes.indexOf(e)},i.prototype._createPass=function(t,i){var r=this,n=t.getEngine();this._volumetricLightScatteringRTT=new e.RenderTargetTexture("volumetricLightScatteringMap",{width:n.getRenderWidth()*i,height:n.getRenderHeight()*i},t,!1,!0,e.Engine.TEXTURETYPE_UNSIGNED_INT),this._volumetricLightScatteringRTT.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.renderList=null,this._volumetricLightScatteringRTT.renderParticles=!1;var o=this.getCamera();o?o.customRenderTargets.push(this._volumetricLightScatteringRTT):t.customRenderTargets.push(this._volumetricLightScatteringRTT);var s,a=function(t){var i=t.getRenderingMesh();if(!r._meshExcluded(i)){var n=t.getMaterial();if(n){var o=i.getScene(),s=o.getEngine();s.setState(n.backFaceCulling);var a=i._getInstancesRenderList(t._id);if(!a.mustReturn){var l=s.getCaps().instancedArrays&&null!==a.visibleInstances[t._id];if(r.isReady(t,l)){var h=r._volumetricLightScatteringPass;if(i===r.mesh&&(h=t.effect?t.effect:n.getEffect()),s.enableEffect(h),i._bind(t,h,e.Material.TriangleFillMode),i===r.mesh)n.bind(i.getWorldMatrix(),i);else{if(r._volumetricLightScatteringPass.setMatrix("viewProjection",o.getTransformMatrix()),n&&n.needAlphaTesting()){var u=n.getAlphaTestTexture();r._volumetricLightScatteringPass.setTexture("diffuseSampler",u),u&&r._volumetricLightScatteringPass.setMatrix("diffuseMatrix",u.getTextureMatrix())}i.useBones&&i.computeBonesUsingShaders&&i.skeleton&&r._volumetricLightScatteringPass.setMatrices("mBones",i.skeleton.getTransformMatrices(i))}i._processRendering(t,r._volumetricLightScatteringPass,e.Material.TriangleFillMode,a,l,(function(e,t){return h.setMatrix("world",t)}))}}}}},l=new e.Color4(0,0,0,1);this._volumetricLightScatteringRTT.onBeforeRenderObservable.add((function(){s=t.clearColor,t.clearColor=l})),this._volumetricLightScatteringRTT.onAfterRenderObservable.add((function(){t.clearColor=s})),this._volumetricLightScatteringRTT.customRenderFunction=function(i,r,n,o){var s,l=t.getEngine();if(o.length){for(l.setColorWrite(!1),s=0;st._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0})),l.setAlphaMode(e.Engine.ALPHA_COMBINE),s=0;s0)return Math.max(n,3)}return Math.max(t,3)},i.prototype._gaussianWeight=function(e){var t=Math.sqrt(2*Math.PI)*(1/3),i=-e*e/(1/3*2*(1/3));return 1/t*Math.exp(i)},i.prototype._glslFloat=function(e,t){return void 0===t&&(t=8),e.toFixed(t).replace(/0+$/,"")},i})(e.PostProcess);e.BlurPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a,l){void 0===n&&(n=null),void 0===o&&(o=null),void 0===s&&(s=null),void 0===a&&(a=null),void 0===l&&(l=null);var h=t.call(this,i,r.getScene())||this;return h.name=i,h.children=new Array,h.animations=new Array,h._index=null,h._worldTransform=new e.Matrix,h._absoluteTransform=new e.Matrix,h._invertedAbsoluteTransform=new e.Matrix,h._scaleMatrix=e.Matrix.Identity(),h._scaleVector=e.Vector3.One(),h._negateScaleChildren=e.Vector3.One(),h._scalingDeterminant=1,h._skeleton=r,h._localMatrix=o||e.Matrix.Identity(),h._restPose=s||h._localMatrix.clone(),h._baseMatrix=a||h._localMatrix.clone(),h._index=l,r.bones.push(h),h.setParent(n,!1),h._updateDifferenceMatrix(),h}return __extends(i,t),Object.defineProperty(i.prototype,"_matrix",{get:function(){return this._localMatrix},set:function(e){this._localMatrix?this._localMatrix.copyFrom(e):this._localMatrix=e},enumerable:!0,configurable:!0}),i.prototype.getSkeleton=function(){return this._skeleton},i.prototype.getParent=function(){return this._parent},i.prototype.setParent=function(e,t){if(void 0===t&&(t=!0),this._parent!==e){if(this._parent){var i=this._parent.children.indexOf(this);-1!==i&&this._parent.children.splice(i,1)}this._parent=e,this._parent&&this._parent.children.push(this),t&&this._updateDifferenceMatrix()}},i.prototype.getLocalMatrix=function(){return this._localMatrix},i.prototype.getBaseMatrix=function(){return this._baseMatrix},i.prototype.getRestPose=function(){return this._restPose},i.prototype.returnToRest=function(){this.updateMatrix(this._restPose.clone())},i.prototype.getWorldMatrix=function(){return this._worldTransform},i.prototype.getInvertedAbsoluteTransform=function(){return this._invertedAbsoluteTransform},i.prototype.getAbsoluteTransform=function(){return this._absoluteTransform},Object.defineProperty(i.prototype,"position",{get:function(){return this.getPosition()},set:function(e){this.setPosition(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rotation",{get:function(){return this.getRotation()},set:function(e){this.setRotation(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rotationQuaternion",{get:function(){return this.getRotationQuaternion()},set:function(e){this.setRotationQuaternion(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scaling",{get:function(){return this.getScale()},set:function(e){this.setScale(e.x,e.y,e.z)},enumerable:!0,configurable:!0}),i.prototype.updateMatrix=function(e,t){void 0===t&&(t=!0),this._baseMatrix=e.clone(),this._localMatrix=e.clone(),this._skeleton._markAsDirty(),t&&this._updateDifferenceMatrix()},i.prototype._updateDifferenceMatrix=function(e){e||(e=this._baseMatrix),this._parent?e.multiplyToRef(this._parent._absoluteTransform,this._absoluteTransform):this._absoluteTransform.copyFrom(e),this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform);for(var t=0;t=u&&a.frame<=c&&(n?(h=a.value.clone(),m?(l=h.getTranslation(),h.setTranslation(l.scaleInPlace(g))):v&&o?(l=h.getTranslation(),h.setTranslation(l.multiplyInPlace(o))):h=a.value):h=a.value,y.push({frame:a.frame+r,value:h}));return this.animations[0].createRange(i,u+r,c+r),!0},i.prototype.translate=function(t,r,n){void 0===r&&(r=e.Space.LOCAL);var o=this.getLocalMatrix();if(r==e.Space.LOCAL)o.m[12]+=t.x,o.m[13]+=t.y,o.m[14]+=t.z;else{var s=null;n&&(s=n.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var a=i._tmpMats[0],l=i._tmpVecs[0];this._parent&&(n&&s?(a.copyFrom(this._parent.getAbsoluteTransform()),a.multiplyToRef(s,a)):a.copyFrom(this._parent.getAbsoluteTransform())),a.m[12]=0,a.m[13]=0,a.m[14]=0,a.invert(),e.Vector3.TransformCoordinatesToRef(t,a,l),o.m[12]+=l.x,o.m[13]+=l.y,o.m[14]+=l.z}this.markAsDirty()},i.prototype.setPosition=function(t,r,n){void 0===r&&(r=e.Space.LOCAL);var o=this.getLocalMatrix();if(r==e.Space.LOCAL)o.m[12]=t.x,o.m[13]=t.y,o.m[14]=t.z;else{var s=null;n&&(s=n.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var a=i._tmpMats[0],l=i._tmpVecs[0];this._parent&&(n&&s?(a.copyFrom(this._parent.getAbsoluteTransform()),a.multiplyToRef(s,a)):a.copyFrom(this._parent.getAbsoluteTransform())),a.invert(),e.Vector3.TransformCoordinatesToRef(t,a,l),o.m[12]=l.x,o.m[13]=l.y,o.m[14]=l.z}this.markAsDirty()},i.prototype.setAbsolutePosition=function(t,i){this.setPosition(t,e.Space.WORLD,i)},i.prototype.setScale=function(e,t,i,r){void 0===r&&(r=!1),this.animations[0]&&!this.animations[0].hasRunningRuntimeAnimations&&(r||(this._negateScaleChildren.x=1/e,this._negateScaleChildren.y=1/t,this._negateScaleChildren.z=1/i),this._syncScaleVector()),this.scale(e/this._scaleVector.x,t/this._scaleVector.y,i/this._scaleVector.z,r)},i.prototype.scale=function(t,r,n,o){void 0===o&&(o=!1);var s=this.getLocalMatrix(),a=i._tmpMats[0];a.copyFrom(s);var l=i._tmpMats[1];l.copyFrom(a),l.invert();var h=i._tmpMats[2];e.Matrix.FromValuesToRef(t,0,0,0,0,r,0,0,0,0,n,0,0,0,0,1,h),this._scaleMatrix.multiplyToRef(h,this._scaleMatrix),this._scaleVector.x*=t,this._scaleVector.y*=r,this._scaleVector.z*=n,s.multiplyToRef(l,s),s.multiplyToRef(h,s),s.multiplyToRef(a,s);var u=this.getParent();u?s.multiplyToRef(u.getAbsoluteTransform(),this.getAbsoluteTransform()):this.getAbsoluteTransform().copyFrom(s);var c=this.children.length;h.invert();for(var f=0;f0&&(this._rightHandedSystem=!0,this._bendAxis.x=0,this._bendAxis.y=0,this._bendAxis.z=-1,n.x>n.y&&n.x>n.z&&(this._adjustRoll=.5*Math.PI,this._bendAxis.z=1)),this._bone1.length){var o=this._bone1.getScale(),s=this._bone2.getScale();this._bone1Length=this._bone1.length*o.y*this.mesh.scaling.y,this._bone2Length=this._bone2.length*s.y*this.mesh.scaling.y}else if(this._bone1.children[0]){t.computeWorldMatrix(!0);var a=this._bone2.children[0].getAbsolutePosition(t),l=this._bone2.getAbsolutePosition(t),h=this._bone1.getAbsolutePosition(t);this._bone1Length=e.Vector3.Distance(a,l),this._bone2Length=e.Vector3.Distance(l,h)}this._bone1.getRotationMatrixToRef(e.Space.WORLD,t,this._bone1Mat),this.maxAngle=Math.PI,r&&(r.targetMesh&&(this.targetMesh=r.targetMesh,this.targetMesh.computeWorldMatrix(!0)),r.poleTargetMesh?(this.poleTargetMesh=r.poleTargetMesh,this.poleTargetMesh.computeWorldMatrix(!0)):r.poleTargetBone?this.poleTargetBone=r.poleTargetBone:this._bone1.getParent()&&(this.poleTargetBone=this._bone1.getParent()),r.poleTargetLocalOffset&&this.poleTargetLocalOffset.copyFrom(r.poleTargetLocalOffset),r.poleAngle&&(this.poleAngle=r.poleAngle),r.bendAxis&&this._bendAxis.copyFrom(r.bendAxis),r.maxAngle&&(this.maxAngle=r.maxAngle),r.slerpAmount&&(this.slerpAmount=r.slerpAmount))}}return Object.defineProperty(t.prototype,"maxAngle",{get:function(){return this._maxAngle},set:function(e){this._setMaxAngle(e)},enumerable:!0,configurable:!0}),t.prototype._setMaxAngle=function(e){e<0&&(e=0),(e>Math.PI||void 0==e)&&(e=Math.PI),this._maxAngle=e;var t=this._bone1Length,i=this._bone2Length;this._maxReach=Math.sqrt(t*t+i*i-2*t*i*Math.cos(e))},t.prototype.update=function(){var i=this._bone1;if(i){var r=this.targetPosition,n=this.poleTargetPosition,o=t._tmpMats[0],s=t._tmpMats[1];this.targetMesh&&r.copyFrom(this.targetMesh.getAbsolutePosition()),this.poleTargetBone?this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset,this.mesh,n):this.poleTargetMesh&&e.Vector3.TransformCoordinatesToRef(this.poleTargetLocalOffset,this.poleTargetMesh.getWorldMatrix(),n);var a=t._tmpVecs[0],l=t._tmpVecs[1],h=t._tmpVecs[2],u=t._tmpVecs[3],c=t._tmpVecs[4],f=t._tmpQuat;i.getAbsolutePositionToRef(this.mesh,a),n.subtractToRef(a,c),0==c.x&&0==c.y&&0==c.z?c.y=1:c.normalize(),r.subtractToRef(a,u),u.normalize(),e.Vector3.CrossToRef(u,c,l),l.normalize(),e.Vector3.CrossToRef(u,l,h),h.normalize(),e.Matrix.FromXYZAxesToRef(h,u,l,o);var d=this._bone1Length,p=this._bone2Length,_=e.Vector3.Distance(a,r);this._maxReach>0&&(_=Math.min(this._maxReach,_));var m=(p*p+_*_-d*d)/(2*p*_),g=(_*_+d*d-p*p)/(2*_*d);m>1&&(m=1),g>1&&(g=1),m<-1&&(m=-1),g<-1&&(g=-1);var v=Math.acos(m),y=Math.acos(g),b=-v-y;if(this._rightHandedSystem)e.Matrix.RotationYawPitchRollToRef(0,0,this._adjustRoll,s),s.multiplyToRef(o,o),e.Matrix.RotationAxisToRef(this._bendAxis,y,s),s.multiplyToRef(o,o);else{var x=t._tmpVecs[5];x.copyFrom(this._bendAxis),x.x*=-1,e.Matrix.RotationAxisToRef(x,-y,s),s.multiplyToRef(o,o)}this.poleAngle&&(e.Matrix.RotationAxisToRef(u,this.poleAngle,s),o.multiplyToRef(s,o)),this._bone1&&(this.slerpAmount<1?(this._slerping||e.Quaternion.FromRotationMatrixToRef(this._bone1Mat,this._bone1Quat),e.Quaternion.FromRotationMatrixToRef(o,f),e.Quaternion.SlerpToRef(this._bone1Quat,f,this.slerpAmount,this._bone1Quat),b=this._bone2Ang*(1-this.slerpAmount)+b*this.slerpAmount,this._bone1.setRotationQuaternion(this._bone1Quat,e.Space.WORLD,this.mesh),this._slerping=!0):(this._bone1.setRotationMatrix(o,e.Space.WORLD,this.mesh),this._bone1Mat.copyFrom(o),this._slerping=!1)),this._bone2.setAxisAngle(this._bendAxis,b,e.Space.LOCAL),this._bone2Ang=b}},t._tmpVecs=[e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero()],t._tmpQuat=e.Quaternion.Identity(),t._tmpMats=[e.Matrix.Identity(),e.Matrix.Identity()],t})();e.BoneIKController=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r,n){if(this.upAxis=e.Vector3.Up(),this.upAxisSpace=e.Space.LOCAL,this.adjustYaw=0,this.adjustPitch=0,this.adjustRoll=0,this.slerpAmount=1,this._boneQuat=e.Quaternion.Identity(),this._slerping=!1,this._firstFrameSkipped=!1,this._fowardAxis=e.Vector3.Forward(),this.mesh=t,this.bone=i,this.target=r,n&&(n.adjustYaw&&(this.adjustYaw=n.adjustYaw),n.adjustPitch&&(this.adjustPitch=n.adjustPitch),n.adjustRoll&&(this.adjustRoll=n.adjustRoll),null!=n.maxYaw?this.maxYaw=n.maxYaw:this.maxYaw=Math.PI,null!=n.minYaw?this.minYaw=n.minYaw:this.minYaw=-Math.PI,null!=n.maxPitch?this.maxPitch=n.maxPitch:this.maxPitch=Math.PI,null!=n.minPitch?this.minPitch=n.minPitch:this.minPitch=-Math.PI,null!=n.slerpAmount&&(this.slerpAmount=n.slerpAmount),null!=n.upAxis&&(this.upAxis=n.upAxis),null!=n.upAxisSpace&&(this.upAxisSpace=n.upAxisSpace),null!=n.yawAxis||null!=n.pitchAxis)){var o=e.Axis.Y,s=e.Axis.X;null!=n.yawAxis&&(o=n.yawAxis.clone(),o.normalize()),null!=n.pitchAxis&&(s=n.pitchAxis.clone(),s.normalize());var a=e.Vector3.Cross(s,o);this._transformYawPitch=e.Matrix.Identity(),e.Matrix.FromXYZAxesToRef(s,o,a,this._transformYawPitch),this._transformYawPitchInv=this._transformYawPitch.clone(),this._transformYawPitch.invert()}i.getParent()||this.upAxisSpace!=e.Space.BONE||(this.upAxisSpace=e.Space.LOCAL)}return Object.defineProperty(t.prototype,"minYaw",{get:function(){return this._minYaw},set:function(e){this._minYaw=e,this._minYawSin=Math.sin(e),this._minYawCos=Math.cos(e),null!=this._maxYaw&&(this._midYawConstraint=.5*this._getAngleDiff(this._minYaw,this._maxYaw)+this._minYaw,this._yawRange=this._maxYaw-this._minYaw)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxYaw",{get:function(){return this._maxYaw},set:function(e){this._maxYaw=e,this._maxYawSin=Math.sin(e),this._maxYawCos=Math.cos(e),null!=this._minYaw&&(this._midYawConstraint=.5*this._getAngleDiff(this._minYaw,this._maxYaw)+this._minYaw,this._yawRange=this._maxYaw-this._minYaw)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"minPitch",{get:function(){return this._minPitch},set:function(e){this._minPitch=e,this._minPitchTan=Math.tan(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxPitch",{get:function(){return this._maxPitch},set:function(e){this._maxPitch=e,this._maxPitchTan=Math.tan(e)},enumerable:!0,configurable:!0}),t.prototype.update=function(){if(this.slerpAmount<1&&!this._firstFrameSkipped)return void(this._firstFrameSkipped=!0);var i=this.bone,r=t._tmpVecs[0];i.getAbsolutePositionToRef(this.mesh,r);var n=this.target,o=t._tmpMats[0],s=t._tmpMats[1],a=this.mesh,l=i.getParent(),h=t._tmpVecs[1];h.copyFrom(this.upAxis),this.upAxisSpace==e.Space.BONE&&l?(this._transformYawPitch&&e.Vector3.TransformCoordinatesToRef(h,this._transformYawPitchInv,h),l.getDirectionToRef(h,this.mesh,h)):this.upAxisSpace==e.Space.LOCAL&&(a.getDirectionToRef(h,h),1==a.scaling.x&&1==a.scaling.y&&1==a.scaling.z||h.normalize());var u=!1,c=!1;if(this._maxYaw==Math.PI&&this._minYaw==-Math.PI||(u=!0),this._maxPitch==Math.PI&&this._minPitch==-Math.PI||(c=!0),u||c){var f=t._tmpMats[2],d=t._tmpMats[3];if(this.upAxisSpace==e.Space.BONE&&1==h.y&&l)l.getRotationMatrixToRef(e.Space.WORLD,this.mesh,f);else if(this.upAxisSpace!=e.Space.LOCAL||1!=h.y||l){var p=t._tmpVecs[2];p.copyFrom(this._fowardAxis),this._transformYawPitch&&e.Vector3.TransformCoordinatesToRef(p,this._transformYawPitchInv,p),l?l.getDirectionToRef(p,this.mesh,p):a.getDirectionToRef(p,p);var _=e.Vector3.Cross(h,p);_.normalize();var p=e.Vector3.Cross(_,h);e.Matrix.FromXYZAxesToRef(_,h,p,f)}else f.copyFrom(a.getWorldMatrix());f.invertToRef(d);var m=null;if(c){var g=t._tmpVecs[3];n.subtractToRef(r,g),e.Vector3.TransformCoordinatesToRef(g,d,g),m=Math.sqrt(g.x*g.x+g.z*g.z);var v=Math.atan2(g.y,m),y=v;v>this._maxPitch?(g.y=this._maxPitchTan*m,y=this._maxPitch):vthis._maxYaw||bMath.PI?this._isAngleBetween(b,this._maxYaw,this._midYawConstraint)?(g.z=this._maxYawCos*m,g.x=this._maxYawSin*m,x=this._maxYaw):this._isAngleBetween(b,this._midYawConstraint,this._minYaw)&&(g.z=this._minYawCos*m,g.x=this._minYawSin*m,x=this._minYaw):b>this._maxYaw?(g.z=this._maxYawCos*m,g.x=this._maxYawSin*m,x=this._maxYaw):bMath.PI){var T=t._tmpVecs[8];T.copyFrom(e.Axis.Z),this._transformYawPitch&&e.Vector3.TransformCoordinatesToRef(T,this._transformYawPitchInv,T);var A=e.BoneLookController._tmpMats[4];this._boneQuat.toRotationMatrix(A),this.mesh.getWorldMatrix().multiplyToRef(A,A),e.Vector3.TransformCoordinatesToRef(T,A,T),e.Vector3.TransformCoordinatesToRef(T,d,T);var E=Math.atan2(T.x,T.z);if(this._getAngleBetween(E,b)>this._getAngleBetween(E,this._midYawConstraint)){null==m&&(m=Math.sqrt(g.x*g.x+g.z*g.z));var P=this._getAngleBetween(E,this._maxYaw);this._getAngleBetween(E,this._minYaw)Math.PI?i-=2*Math.PI:i<-Math.PI&&(i+=2*Math.PI),i},t.prototype._getAngleBetween=function(e,t){e%=2*Math.PI,e=e<0?e+2*Math.PI:e,t%=2*Math.PI,t=t<0?t+2*Math.PI:t;var i=0;return i=eMath.PI&&(i=2*Math.PI-i),i},t.prototype._isAngleBetween=function(e,t,i){if(e%=2*Math.PI,e=e<0?e+2*Math.PI:e,t%=2*Math.PI,t=t<0?t+2*Math.PI:t,i%=2*Math.PI,i=i<0?i+2*Math.PI:i,tt&&ei&&e-1&&this._meshesWithPoseMatrix.splice(t,1)},t.prototype._computeTransformMatrices=function(e,t){this.onBeforeComputeObservable.notifyObservers(this);for(var i=0;i0&&(n.animation=i.animations[0].serialize()),e.ranges=[];for(var o in this._ranges){var s=this._ranges[o];if(s){var a={};a.name=o,a.from=s.from,a.to=s.to,e.ranges.push(a)}}}return e},t.Parse=function(i,r){var n=new t(i.name,i.id,r);i.dimensionsAtRest&&(n.dimensionsAtRest=e.Vector3.FromArray(i.dimensionsAtRest)),n.needInitialSkinMatrix=i.needInitialSkinMatrix;var o;for(o=0;o-1&&(a=n.bones[s.parentBoneIndex]);var l=s.rest?e.Matrix.FromArray(s.rest):null,h=new e.Bone(s.name,n,a,e.Matrix.FromArray(s.matrix),l);s.length&&(h.length=s.length),s.animation&&h.animations.push(e.Animation.Parse(s.animation))}if(i.ranges)for(o=0;o0&&(e=this._meshesWithPoseMatrix[0].getPoseMatrix()),e},t.prototype.sortBones=function(){for(var e=new Array,t=new Array(this.bones.length),i=0;iMath.PI;)n-=2*Math.PI;var s=n/Math.PI,a=o/Math.PI;s=.5*s+.5;var l=Math.round(s*i);l<0?l=0:l>=i&&(l=i-1);var h=Math.round(a*r);h<0?h=0:h>=r&&(h=r-1);var u=r-h-1;return{r:t[u*i*3+3*l+0],g:t[u*i*3+3*l+1],b:t[u*i*3+3*l+2]}},t.FACE_FRONT=[new e.Vector3(-1,-1,-1),new e.Vector3(1,-1,-1),new e.Vector3(-1,1,-1),new e.Vector3(1,1,-1)],t.FACE_BACK=[new e.Vector3(1,-1,1),new e.Vector3(-1,-1,1),new e.Vector3(1,1,1),new e.Vector3(-1,1,1)],t.FACE_RIGHT=[new e.Vector3(1,-1,-1),new e.Vector3(1,-1,1),new e.Vector3(1,1,-1),new e.Vector3(1,1,1)],t.FACE_LEFT=[new e.Vector3(-1,-1,1),new e.Vector3(-1,-1,-1),new e.Vector3(-1,1,1),new e.Vector3(-1,1,-1)],t.FACE_DOWN=[new e.Vector3(-1,1,-1),new e.Vector3(1,1,-1),new e.Vector3(-1,1,1),new e.Vector3(1,1,1)],t.FACE_UP=[new e.Vector3(-1,-1,1),new e.Vector3(1,-1,1),new e.Vector3(-1,-1,-1),new e.Vector3(1,-1,-1)],t})();t.PanoramaToCubeMapTools=i})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(e){var t=(function(){function t(){}return t.Ldexp=function(e,t){return t>1023?e*Math.pow(2,1023)*Math.pow(2,t-1023):t<-1074?e*Math.pow(2,-1074)*Math.pow(2,t+1074):e*Math.pow(2,t)},t.Rgbe2float=function(e,t,i,r,n,o){n>0?(n=this.Ldexp(1,n-136),e[o+0]=t*n,e[o+1]=i*n,e[o+2]=r*n):(e[o+0]=0,e[o+1]=0,e[o+2]=0)},t.readStringLine=function(e,t){for(var i="",r="",n=t;n32767)throw"HDR Bad header format, unsupported size";return s+=r.length+1,{height:t,width:i,dataPosition:s}},t.GetCubeMapTextureData=function(t,i){var r=new Uint8Array(t),n=this.RGBE_ReadHeader(r),o=this.RGBE_ReadPixels_RLE(r,n);return e.PanoramaToCubeMapTools.ConvertPanoramaToCubemap(o,n.width,n.height,i)},t.RGBE_ReadPixels=function(e,t){return this.RGBE_ReadPixels_RLE(e,t)},t.RGBE_ReadPixels_RLE=function(e,t){for(var i,r,n,o,s,a=t.height,l=t.width,h=t.dataPosition,u=0,c=0,f=0,d=new ArrayBuffer(4*l),p=new Uint8Array(d),_=new ArrayBuffer(t.width*t.height*4*3),m=new Float32Array(_);a>0;){if(i=e[h++],r=e[h++],n=e[h++],o=e[h++],2!=i||2!=r||128&n)throw"HDR Bad header format, not RLE";if((n<<8|o)!=l)throw"HDR Bad header format, wrong scan line width";for(u=0,f=0;f<4;f++)for(c=(f+1)*l;u128){if(0==(s=i-128)||s>c-u)throw"HDR Bad Format, bad scanline data (run)";for(;s-- >0;)p[u++]=r}else{if(0==(s=i)||s>c-u)throw"HDR Bad Format, bad scanline data (non-run)";if(p[u++]=r,--s>0)for(var g=0;g>s,2),l=0;l<6;l++){var h=r.subarray(o,o+a);n[s].push(h),o+=a}}return n}:null,s=function(n){var s=t.getScene();if(!s)return null;var a=new Int32Array(n);r=new Float32Array(n);var l=a[0];if(t._size=a[1],!t._texture)return null;t._texture.updateSize(t._size,t._size);var h=new e.SphericalPolynomial;h.x.copyFromFloats(r[2],r[3],r[4]),h.y.copyFromFloats(r[5],r[6],r[7]),h.z.copyFromFloats(r[8],r[9],r[10]),h.xx.copyFromFloats(r[11],r[12],r[13]),h.yy.copyFromFloats(r[14],r[15],r[16]),h.zz.copyFromFloats(r[17],r[18],r[19]),h.xy.copyFromFloats(r[20],r[21],r[22]),h.yz.copyFromFloats(r[23],r[24],r[25]),h.zx.copyFromFloats(r[26],r[27],r[28]),t.sphericalPolynomial=h,i=a[29];for(var u=30,c=[],f=3*Math.pow(t._size,2),d=0;d<6;d++)c.push(r.subarray(u,u+f)),u+=f;for(var p=[],_=null,m=0;m<6;m++){var g=null;if(1===l){g=c[[0,2,4,1,3,5][m]]}if(!o&&g){if(!s.getEngine().getCaps().textureFloat){var v=new ArrayBuffer(f);_=new Uint8Array(v)}for(var y=0;y255){var E=255/A;b*=E,x*=E,T*=E}_[3*y+0]=b,_[3*y+1]=x,_[3*y+2]=T}}_?p.push(_):p.push(g)}return p};n&&(this._texture=n.getEngine().createRawCubeTextureFromUrl(this.url,n,this._size,e.Engine.TEXTUREFORMAT_RGB,n.getEngine().getCaps().textureFloat?e.Engine.TEXTURETYPE_FLOAT:e.Engine.TEXTURETYPE_UNSIGNED_INT,this._noMipmap,s,o,this._onLoad,this._onError))},i.prototype.loadHDRTexture=function(){var t=this,r=function(r){var n=t.getScene();if(!n)return null;var o=e.Internals.HDRTools.GetCubeMapTextureData(r,t._size);if(t._generateHarmonics){var s=e.Internals.CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial(o);t.sphericalPolynomial=s}for(var a=[],l=null,h=0;h<6;h++){if(!n.getEngine().getCaps().textureFloat){var u=new ArrayBuffer(t._size*t._size*3);l=new Uint8Array(u)}var c=o[i._facesMapping[h]];if(t._useInGammaSpace||l)for(var f=0;f255){var g=255/m;d*=g,p*=g,_*=g}l[3*f+0]=d,l[3*f+1]=p,l[3*f+2]=_}l?a.push(l):a.push(c)}return a},n=this.getScene();n&&(this._texture=n.getEngine().createRawCubeTextureFromUrl(this.url,n,this._size,e.Engine.TEXTUREFORMAT_RGB,n.getEngine().getCaps().textureFloat?e.Engine.TEXTURETYPE_FLOAT:e.Engine.TEXTURETYPE_UNSIGNED_INT,this._noMipmap,r,null,this._onLoad,this._onError))},i.prototype.loadTexture=function(){this._isBABYLONPreprocessed?this.loadBabylonTexture():this.loadHDRTexture()},i.prototype.clone=function(){var e=this.getScene();if(!e)return this;var t=this._isBABYLONPreprocessed?null:this._size,r=new i(this.url,e,t,this._noMipmap,this._generateHarmonics,this._useInGammaSpace,this._usePMREMGenerator);return r.level=this.level,r.wrapU=this.wrapU,r.wrapV=this.wrapV,r.coordinatesIndex=this.coordinatesIndex,r.coordinatesMode=this.coordinatesMode,r},i.prototype.delayLoad=function(){this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap),this._texture||this.loadTexture())},i.prototype.getReflectionTextureMatrix=function(){return this._textureMatrix},i.prototype.setReflectionTextureMatrix=function(e){this._textureMatrix=e},i.Parse=function(t,i,r){var n=null;if(t.name&&!t.isRenderTarget){var o=t.isBABYLONPreprocessed?null:t.size;n=new e.HDRCubeTexture(r+t.name,i,o,t.noMipmap,t.generateHarmonics,t.useInGammaSpace,t.usePMREMGenerator),n.name=t.name,n.hasAlpha=t.hasAlpha,n.level=t.level,n.coordinatesMode=t.coordinatesMode,n.isBlocking=t.isBlocking}return n},i.prototype.serialize=function(){if(!this.name)return null;var e={};return e.name=this.name,e.hasAlpha=this.hasAlpha,e.isCube=!0,e.level=this.level,e.size=this._size,e.coordinatesMode=this.coordinatesMode,e.useInGammaSpace=this._useInGammaSpace,e.generateHarmonics=this._generateHarmonics,e.usePMREMGenerator=this._usePMREMGenerator,e.isBABYLONPreprocessed=this._isBABYLONPreprocessed,e.customType="BABYLON.HDRCubeTexture",e.noMipmap=this._noMipmap,e.isBlocking=this._isBlocking,e},i.generateBabylonHDROnDisk=function(e,t,r){void 0===r&&(r=null);var n=function(e){var t=new Blob([e],{type:"application/octet-stream"}),i=window.URL.createObjectURL(t),r=document.createElement("a");document.body.appendChild(r),r.style.display="none",r.href=i,r.download="envmap.babylon.hdr",r.click()};i.generateBabylonHDR(e,t,n,r)},i.generateBabylonHDR=function(t,i,r,n){void 0===n&&(n=null),t&&e.Tools.IsExponentOfTwo(i)&&e.Tools.Error("Generation of Babylon HDR is coming back in 3.1.")},i._facesMapping=["right","left","up","down","front","back"],i})(e.BaseTexture);e.HDRCubeTexture=t})(BABYLON||(BABYLON={}));var Earcut;!(function(e){function t(e,t,r){r=r||2;var o=t&&t.length,s=o?t[0]*r:e.length,a=i(e,0,s,r,!0),l=new Array;if(!a)return l;var u,c,f,d,p=0,_=0,m=0;if(o&&(a=h(e,t,a,r)),e.length>80*r){p=u=e[0],_=c=e[1];for(var g=r;gu&&(u=f),d>c&&(c=d);m=Math.max(u-p,c-_)}return n(a,l,r,p,_,m,0),l}function i(e,t,i,r,n){var o,s=null;if(n===R(e,t,i,r)>0)for(o=t;o=t;o-=r)s=M(o,e[o],e[o+1],s);return s&&b(s,s.next)&&(S(s),s=s.next),s}function r(e,t){if(!e)return e;t||(t=e);var i,r=e;do{if(i=!1,r.steiner||!b(r,r.next)&&0!==y(r.prev,r,r.next))r=r.next;else{if(S(r),(r=t=r.prev)===r.next)return;i=!0}}while(i||r!==t);return t}function n(e,t,i,h,u,c,f){if(e){!f&&c&&d(e,h,u,c);for(var p,_,m=e;e.prev!==e.next;)if(p=e.prev,_=e.next,c?s(e,h,u,c):o(e))t.push(p.i/i),t.push(e.i/i),t.push(_.i/i),S(e),e=_.next,m=_.next;else if((e=_)===m){f?1===f?(e=a(e,t,i),n(e,t,i,h,u,c,2)):2===f&&l(e,t,i,h,u,c):n(r(e,void 0),t,i,h,u,c,1);break}}}function o(e){var t=e.prev,i=e,r=e.next;if(y(t,i,r)>=0)return!1;for(var n=e.next.next;n!==e.prev;){if(g(t.x,t.y,i.x,i.y,r.x,r.y,n.x,n.y)&&y(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function s(e,t,i,r){var n=e.prev,o=e,s=e.next;if(y(n,o,s)>=0)return!1;for(var a=n.xo.x?n.x>s.x?n.x:s.x:o.x>s.x?o.x:s.x,u=n.y>o.y?n.y>s.y?n.y:s.y:o.y>s.y?o.y:s.y,c=_(a,l,t,i,r),f=_(h,u,t,i,r),d=e.nextZ;d&&d.z<=f;){if(d!==e.prev&&d!==e.next&&g(n.x,n.y,o.x,o.y,s.x,s.y,d.x,d.y)&&y(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(d=e.prevZ;d&&d.z>=c;){if(d!==e.prev&&d!==e.next&&g(n.x,n.y,o.x,o.y,s.x,s.y,d.x,d.y)&&y(d.prev,d,d.next)>=0)return!1;d=d.prevZ}return!0}function a(e,t,i){var r=e;do{var n=r.prev,o=r.next.next;!b(n,o)&&x(n,r,r.next,o)&&A(n,o)&&A(o,n)&&(t.push(n.i/i),t.push(r.i/i),t.push(o.i/i),S(r),S(r.next),r=e=o),r=r.next}while(r!==e);return r}function l(e,t,i,o,s,a){var l=e;do{for(var h=l.next.next;h!==l.prev;){if(l.i!==h.i&&v(l,h)){var u=P(l,h);return l=r(l,l.next),u=r(u,u.next),n(l,t,i,o,s,a,void 0),void n(u,t,i,o,s,a,void 0)}h=h.next}l=l.next}while(l!==e)}function h(e,t,n,o){var s,a,l,h,f,d=[];for(s=0,a=t.length;s=r.next.y){var a=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=n&&a>s){if(s=a,a===n){if(o===r.y)return r;if(o===r.next.y)return r.next}i=r.x=r.x&&r.x>=u&&g(oi.x)&&A(r,e)&&(i=r,f=l),r=r.next;return i}function d(e,t,i,r){var n=e;do{null===n.z&&(n.z=_(n.x,n.y,t,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,p(n)}function p(e){var t,i,r,n,o,s,a,l,h=1;do{for(i=e,e=null,o=null,s=0;i;){for(s++,r=i,a=0,t=0;t0||l>0&&r;)0===a?(n=r,r=r.nextZ,l--):0!==l&&r?i.z<=r.z?(n=i,i=i.nextZ,a--):(n=r,r=r.nextZ,l--):(n=i,i=i.nextZ,a--),o?o.nextZ=n:e=n,n.prevZ=o,o=n;i=r}o.nextZ=null,h*=2}while(s>1);return e}function _(e,t,i,r,n){return e=32767*(e-i)/n,t=32767*(t-r)/n,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e|t<<1}function m(e){var t=e,i=e;do{t.x=0&&(e-s)*(r-a)-(i-s)*(t-a)>=0&&(i-s)*(o-a)-(n-s)*(r-a)>=0}function v(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!T(e,t)&&A(e,t)&&A(t,e)&&E(e,t)}function y(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function b(e,t){return e.x===t.x&&e.y===t.y}function x(e,t,i,r){return!!(b(e,t)&&b(i,r)||b(e,r)&&b(i,t))||y(e,t,i)>0!=y(e,t,r)>0&&y(i,r,e)>0!=y(i,r,t)>0}function T(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&x(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function A(e,t){return y(e.prev,e,e.next)<0?y(e,t,e.next)>=0&&y(e,e.prev,t)>=0:y(e,t,e.prev)<0||y(e,e.next,t)<0}function E(e,t){var i=e,r=!1,n=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&n<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==e);return r}function P(e,t){var i=new I(e.i,e.x,e.y),r=new I(t.i,t.x,t.y),n=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=n,n.prev=i,r.next=i,i.prev=r,o.next=r,r.prev=o,r}function M(e,t,i,r){var n=new I(e,t,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function S(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function C(e,t,i,r){var n=t&&t.length,o=n?t[0]*i:e.length,s=Math.abs(R(e,0,o,i));if(n)for(var a=0,l=t.length;a0&&(r+=e[n-1].length,i.holes.push(r))}return i}e.earcut=t;var I=(function(){function e(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}return e})();e.deviation=C,e.flatten=O})(Earcut||(Earcut={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i){var r=e.call(this,t.x,t.y)||this;return r.index=i,r}return __extends(t,e),t})(e.Vector2),i=(function(){function i(){this.elements=new Array}return i.prototype.add=function(e){var i=this,r=new Array;return e.forEach((function(e){if(0===r.length||!e.equalsWithEpsilon(r[0])){var n=new t(e,i.elements.length);r.push(n),i.elements.push(n)}})),r},i.prototype.computeBounds=function(){var t=new e.Vector2(this.elements[0].x,this.elements[0].y),i=new e.Vector2(this.elements[0].x,this.elements[0].y);return this.elements.forEach((function(e){e.xi.x&&(i.x=e.x),e.yi.y&&(i.y=e.y)})),{min:t,max:i,width:i.x-t.x,height:i.y-t.y}},i})(),r=(function(){function t(){}return t.Rectangle=function(t,i,r,n){return[new e.Vector2(t,i),new e.Vector2(r,i),new e.Vector2(r,n),new e.Vector2(t,n)]},t.Circle=function(t,i,r,n){void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=32);for(var o=new Array,s=0,a=2*Math.PI/n,l=0;l0){var f=s.length/3;this._points.elements.forEach((function(e){o.push(0,-1,0),s.push(e.x,-i,e.y),a.push(1-(e.x-l.min.x)/l.width,1-(e.y-l.min.y)/l.height)}));for(var d=h.length,c=0;cs.elements.length-1?s.elements[0]:s.elements[c+1],t.push(d.x,0,d.y),t.push(d.x,-a,d.y),t.push(f.x,0,f.y),t.push(f.x,-a,f.y);var p=new e.Vector3(d.x,0,d.y),_=new e.Vector3(f.x,0,f.y),m=_.subtract(p),g=new e.Vector3(0,1,0),v=e.Vector3.Cross(m,g);v=v.normalize(),r.push(u/o.width,0),r.push(u/o.width,1),u+=m.length(),r.push(u/o.width,0),r.push(u/o.width,1),l?(i.push(v.x,v.y,v.z),i.push(v.x,v.y,v.z),i.push(v.x,v.y,v.z),i.push(v.x,v.y,v.z),n.push(h),n.push(h+2),n.push(h+1),n.push(h+1),n.push(h+2),n.push(h+3)):(i.push(-v.x,-v.y,-v.z),i.push(-v.x,-v.y,-v.z),i.push(-v.x,-v.y,-v.z),i.push(-v.x,-v.y,-v.z),n.push(h),n.push(h+1),n.push(h+2),n.push(h+1),n.push(h+3),n.push(h+2)),h+=4}},t})();e.PolygonMeshBuilder=n})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=0,i=(function(){function t(e,t,i){ this.pos=e,this.normal=t,this.uv=i}return t.prototype.clone=function(){return new t(this.pos.clone(),this.normal.clone(),this.uv.clone())},t.prototype.flip=function(){this.normal=this.normal.scale(-1)},t.prototype.interpolate=function(i,r){return new t(e.Vector3.Lerp(this.pos,i.pos,r),e.Vector3.Lerp(this.normal,i.normal,r),e.Vector2.Lerp(this.uv,i.uv,r))},t})(),r=(function(){function t(e,t){this.normal=e,this.w=t}return t.FromPoints=function(i,r,n){var o=n.subtract(i),s=r.subtract(i);if(0===o.lengthSquared()||0===s.lengthSquared())return null;var a=e.Vector3.Normalize(e.Vector3.Cross(o,s));return new t(a,e.Vector3.Dot(a,i))},t.prototype.clone=function(){return new t(this.normal.clone(),this.w)},t.prototype.flip=function(){this.normal.scaleInPlace(-1),this.w=-this.w},t.prototype.splitPolygon=function(i,r,o,s,a){var l,h,u=0,c=[];for(l=0;lt.EPSILON?1:0;u|=f,c.push(f)}switch(u){case 0:(e.Vector3.Dot(this.normal,i.plane.normal)>0?r:o).push(i);break;case 1:s.push(i);break;case 2:a.push(i);break;case 3:var d=[],p=[];for(l=0;l=3&&(x=new n(d,i.shared),x.plane&&s.push(x)),p.length>=3&&(x=new n(p,i.shared),x.plane&&a.push(x))}},t.EPSILON=1e-5,t})(),n=(function(){function e(e,t){this.vertices=e,this.shared=t,this.plane=r.FromPoints(e[0].pos,e[1].pos,e[2].pos)}return e.prototype.clone=function(){return new e(this.vertices.map((function(e){return e.clone()})),this.shared)},e.prototype.flip=function(){this.vertices.reverse().map((function(e){e.flip()})),this.plane.flip()},e})(),o=(function(){function e(e){this.plane=null,this.front=null,this.back=null,this.polygons=new Array,e&&this.build(e)}return e.prototype.clone=function(){var t=new e;return t.plane=this.plane&&this.plane.clone(),t.front=this.front&&this.front.clone(),t.back=this.back&&this.back.clone(),t.polygons=this.polygons.map((function(e){return e.clone()})),t},e.prototype.invert=function(){for(var e=0;e0&&(t.x-=this.viewportBorder,t.y-=this.viewportBorder,t.width+=2*this.viewportBorder,t.height+=2*this.viewportBorder,i.x+=this.viewportBorder,i.y+=this.viewportBorder,this._positionX+=this.viewportBorder,this._positionY+=this.viewportBorder),i.z>0&&(this._positionX>t.x&&this._positionXt.y&&(this._positionY,t.y,t.height),!0)},t.prototype._isVisible=function(){if(!this._isEnabled||!this._scene.activeCamera)return!1;var t=this.getEmitterPosition(),i=t.subtract(this._scene.activeCamera.globalPosition),r=i.length();i.normalize();var n=new e.Ray(this._scene.activeCamera.globalPosition,i),o=this._scene.pickWithRay(n,this.meshesSelectionPredicate,!0);return!o||!o.hit||o.distance>r},t.prototype.render=function(){if(!this._effect.isReady()||!this._scene.activeCamera)return!1;var t=this._scene.getEngine(),i=this._scene.activeCamera.viewport,r=i.toGlobal(t.getRenderWidth(!0),t.getRenderHeight(!0));if(!this.computeEffectivePosition(r))return!1;if(!this._isVisible())return!1;var n,o;n=this._positionXr.x+r.width-this.borderLimit?this._positionX-r.x-r.width+this.borderLimit:0,o=this._positionYr.y+r.height-this.borderLimit?this._positionY-r.y-r.height+this.borderLimit:0;var s=n>o?n:o;(s-=this.viewportBorder)>this.borderLimit&&(s=this.borderLimit);var a=1-s/this.borderLimit;if(a<0)return!1;a>1&&(a=1),this.viewportBorder>0&&(r.x+=this.viewportBorder,r.y+=this.viewportBorder,r.width-=2*this.viewportBorder,r.height-=2*this.viewportBorder,this._positionX-=this.viewportBorder,this._positionY-=this.viewportBorder);var l=r.x+r.width/2,h=r.y+r.height/2,u=l-this._positionX,c=h-this._positionY;t.enableEffect(this._effect),t.setState(!1),t.setDepthBuffer(!1),t.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect);for(var f=0;f-1?this._onBeforePhysicsStepCallbacks.splice(i,1):e.Tools.Warn("Function to remove was not found")},t.prototype.registerAfterPhysicsStep=function(e){this._onAfterPhysicsStepCallbacks.push(e)},t.prototype.unregisterAfterPhysicsStep=function(t){var i=this._onAfterPhysicsStepCallbacks.indexOf(t);i>-1?this._onAfterPhysicsStepCallbacks.splice(i,1):e.Tools.Warn("Function to remove was not found")},t.prototype.registerOnPhysicsCollide=function(e,t){var i=e instanceof Array?e:[e];this._onPhysicsCollideCallbacks.push({callback:t,otherImpostors:i})},t.prototype.unregisterOnPhysicsCollide=function(t,i){var r=t instanceof Array?t:[t],n=this._onPhysicsCollideCallbacks.indexOf({callback:i,otherImpostors:r});n>-1?this._onPhysicsCollideCallbacks.splice(n,1):e.Tools.Warn("Function to remove was not found")},t.prototype.getParentsRotation=function(){var t=this.object.parent;for(this._tmpQuat.copyFromFloats(0,0,0,1);t;)t.rotationQuaternion?this._tmpQuat2.copyFrom(t.rotationQuaternion):e.Quaternion.RotationYawPitchRollToRef(t.rotation.y,t.rotation.x,t.rotation.z,this._tmpQuat2),this._tmpQuat.multiplyToRef(this._tmpQuat2,this._tmpQuat),t=t.parent;return this._tmpQuat},t.prototype.applyForce=function(e,t){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().applyForce(this,e,t),this},t.prototype.applyImpulse=function(e,t){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().applyImpulse(this,e,t),this},t.prototype.createJoint=function(t,i,r){var n=new e.PhysicsJoint(i,r);return this.addJoint(t,n),this},t.prototype.addJoint=function(e,t){return this._joints.push({otherImpostor:e,joint:t}),this._physicsEngine&&this._physicsEngine.addJoint(this,e,t),this},t.prototype.sleep=function(){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().sleepBody(this),this},t.prototype.wakeUp=function(){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().wakeUpBody(this),this},t.prototype.clone=function(e){return e?new t(e,this.type,this._options,this._scene):null},t.prototype.dispose=function(){var e=this;this._physicsEngine&&(this._joints.forEach((function(t){e._physicsEngine&&e._physicsEngine.removeJoint(e,t.otherImpostor,t.joint)})),this._physicsEngine.removeImpostor(this),this.parent&&this.parent.forceUpdate(),this._isDisposed=!0)},t.prototype.setDeltaPosition=function(e){this._deltaPosition.copyFrom(e)},t.prototype.setDeltaRotation=function(t){this._deltaRotation||(this._deltaRotation=new e.Quaternion),this._deltaRotation.copyFrom(t),this._deltaRotationConjugated=this._deltaRotation.conjugate()},t.prototype.getBoxSizeToRef=function(e){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this,e),this},t.prototype.getRadius=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getRadius(this):0},t.prototype.syncBoneWithImpostor=function(i,r,n,o,s){var a=t._tmpVecs[0],l=this.object;if(l.rotationQuaternion)if(s){var h=t._tmpQuat;l.rotationQuaternion.multiplyToRef(s,h),i.setRotationQuaternion(h,e.Space.WORLD,r)}else i.setRotationQuaternion(l.rotationQuaternion,e.Space.WORLD,r);a.x=0,a.y=0,a.z=0,n&&(a.x=n.x,a.y=n.y,a.z=n.z,i.getDirectionToRef(a,r,a),void 0!==o&&null!==o||(o=n.length()),a.x*=o,a.y*=o,a.z*=o),i.getParent()?(a.addInPlace(l.getAbsolutePosition()),i.setAbsolutePosition(a,r)):(r.setAbsolutePosition(l.getAbsolutePosition()),r.position.x-=a.x,r.position.y-=a.y,r.position.z-=a.z)},t.prototype.syncImpostorWithBone=function(i,r,n,o,s,a){var l=this.object;if(l.rotationQuaternion)if(s){var h=t._tmpQuat;i.getRotationQuaternionToRef(e.Space.WORLD,r,h),h.multiplyToRef(s,l.rotationQuaternion)}else i.getRotationQuaternionToRef(e.Space.WORLD,r,l.rotationQuaternion);var u=t._tmpVecs[0],c=t._tmpVecs[1];a||(a=t._tmpVecs[2],a.x=0,a.y=1,a.z=0),i.getDirectionToRef(a,r,c),i.getAbsolutePositionToRef(r,u),void 0!==o&&null!==o||!n||(o=n.length()),void 0!==o&&null!==o&&(u.x+=c.x*o,u.y+=c.y*o,u.z+=c.z*o),l.setAbsolutePosition(u)},t.DEFAULT_OBJECT_SIZE=new e.Vector3(1,1,1),t.IDENTITY_QUATERNION=e.Quaternion.Identity(),t._tmpVecs=[e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero()],t._tmpQuat=e.Quaternion.Identity(),t.NoImpostor=0,t.SphereImpostor=1,t.BoxImpostor=2,t.PlaneImpostor=3,t.MeshImpostor=4,t.CylinderImpostor=7,t.ParticleImpostor=8,t.HeightmapImpostor=9,t})();e.PhysicsImpostor=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i){if(void 0===i&&(i=new e.CannonJSPlugin),this._physicsPlugin=i,this._impostors=[],this._joints=[],!this._physicsPlugin.isSupported())throw new Error("Physics Engine "+this._physicsPlugin.name+" cannot be found. Please make sure it is included.");t=t||new e.Vector3(0,-9.807,0),this.setGravity(t),this.setTimeStep()}return t.prototype.setGravity=function(e){this.gravity=e,this._physicsPlugin.setGravity(this.gravity)},t.prototype.setTimeStep=function(e){void 0===e&&(e=1/60),this._physicsPlugin.setTimeStep(e)},t.prototype.getTimeStep=function(){return this._physicsPlugin.getTimeStep()},t.prototype.dispose=function(){this._impostors.forEach((function(e){e.dispose()})),this._physicsPlugin.dispose()},t.prototype.getPhysicsPluginName=function(){return this._physicsPlugin.name},t.prototype.addImpostor=function(e){e.uniqueId=this._impostors.push(e),e.parent||this._physicsPlugin.generatePhysicsBody(e)},t.prototype.removeImpostor=function(e){var t=this._impostors.indexOf(e);if(t>-1){var i=this._impostors.splice(t,1);i.length&&(i[0].physicsBody=null)}},t.prototype.addJoint=function(e,t,i){var r={mainImpostor:e,connectedImpostor:t,joint:i};i.physicsPlugin=this._physicsPlugin,this._joints.push(r),this._physicsPlugin.generateJoint(r)},t.prototype.removeJoint=function(e,t,i){var r=this._joints.filter((function(r){return r.connectedImpostor===t&&r.joint===i&&r.mainImpostor===e}));r.length&&this._physicsPlugin.removeJoint(r[0])},t.prototype._step=function(e){var t=this;this._impostors.forEach((function(e){e.isBodyInitRequired()&&t._physicsPlugin.generatePhysicsBody(e)})),e>.1?e=.1:e<=0&&(e=1/60),this._physicsPlugin.executeStep(e,this._impostors)},t.prototype.getPhysicsPlugin=function(){return this._physicsPlugin},t.prototype.getImpostorForPhysicsObject=function(e){for(var t=0;tr.length)return void e.Tools.Error("Unable to load TGA file - Not enough data");n+=o.id_length;var s=!1,a=!1,l=!1;switch(o.image_type){case t._TYPE_RLE_INDEXED:s=!0;case t._TYPE_INDEXED:a=!0;break;case t._TYPE_RLE_RGB:s=!0;case t._TYPE_RGB:!0;break;case t._TYPE_RLE_GREY:s=!0;case t._TYPE_GREY:l=!0}var h,u,c=o.pixel_size>>3,f=o.width*o.height*c;if(a&&(u=r.subarray(n,n+=o.colormap_length*(o.colormap_size>>3))),s){h=new Uint8Array(f);for(var d,p,_,m=0,g=new Uint8Array(c);n>t._ORIGIN_SHIFT){default:case t._ORIGIN_UL:v=0,b=1,A=o.width,y=0,x=1,T=o.height;break;case t._ORIGIN_BL:v=0,b=1,A=o.width,y=o.height-1,x=-1,T=-1;break;case t._ORIGIN_UR:v=o.width-1,b=-1,A=-1,y=0,x=1,T=o.height;break;case t._ORIGIN_BR:v=o.width-1,b=-1,A=-1,y=o.height-1,x=-1,T=-1}var E="_getImageData"+(l?"Grey":"")+o.pixel_size+"bits",P=t[E](o,u,h,y,x,T,v,b,A);i.texImage2D(i.TEXTURE_2D,0,i.RGBA,o.width,o.height,0,i.RGBA,i.UNSIGNED_BYTE,P)},t._getImageData8bits=function(e,t,i,r,n,o,s,a,l){var h,u,c,f=i,d=t,p=e.width,_=e.height,m=0,g=new Uint8Array(p*_*4);for(c=r;c!==o;c+=n)for(u=s;u!==l;u+=a,m++)h=f[m],g[4*(u+p*c)+3]=255,g[4*(u+p*c)+2]=d[3*h+0],g[4*(u+p*c)+1]=d[3*h+1],g[4*(u+p*c)+0]=d[3*h+2];return g},t._getImageData16bits=function(e,t,i,r,n,o,s,a,l){var h,u,c,f=i,d=e.width,p=e.height,_=0,m=new Uint8Array(d*p*4);for(c=r;c!==o;c+=n)for(u=s;u!==l;u+=a,_+=2)h=f[_+0]+(f[_+1]<<8),m[4*(u+d*c)+0]=(31744&h)>>7,m[4*(u+d*c)+1]=(992&h)>>2,m[4*(u+d*c)+2]=(31&h)>>3,m[4*(u+d*c)+3]=32768&h?0:255;return m},t._getImageData24bits=function(e,t,i,r,n,o,s,a,l){var h,u,c=i,f=e.width,d=e.height,p=0,_=new Uint8Array(f*d*4);for(u=r;u!==o;u+=n)for(h=s;h!==l;h+=a,p+=3)_[4*(h+f*u)+3]=255,_[4*(h+f*u)+2]=c[p+0],_[4*(h+f*u)+1]=c[p+1],_[4*(h+f*u)+0]=c[p+2];return _},t._getImageData32bits=function(e,t,i,r,n,o,s,a,l){var h,u,c=i,f=e.width,d=e.height,p=0,_=new Uint8Array(f*d*4);for(u=r;u!==o;u+=n)for(h=s;h!==l;h+=a,p+=4)_[4*(h+f*u)+2]=c[p+0],_[4*(h+f*u)+1]=c[p+1],_[4*(h+f*u)+0]=c[p+2],_[4*(h+f*u)+3]=c[p+3];return _},t._getImageDataGrey8bits=function(e,t,i,r,n,o,s,a,l){var h,u,c,f=i,d=e.width,p=e.height,_=0,m=new Uint8Array(d*p*4);for(c=r;c!==o;c+=n)for(u=s;u!==l;u+=a,_++)h=f[_],m[4*(u+d*c)+0]=h,m[4*(u+d*c)+1]=h,m[4*(u+d*c)+2]=h,m[4*(u+d*c)+3]=255;return m},t._getImageDataGrey16bits=function(e,t,i,r,n,o,s,a,l){var h,u,c=i,f=e.width,d=e.height,p=0,_=new Uint8Array(f*d*4);for(u=r;u!==o;u+=n)for(h=s;h!==l;h+=a,p+=2)_[4*(h+f*u)+0]=c[p+0],_[4*(h+f*u)+1]=c[p+0],_[4*(h+f*u)+2]=c[p+0],_[4*(h+f*u)+3]=c[p+1];return _},t._TYPE_INDEXED=1,t._TYPE_RGB=2,t._TYPE_GREY=3,t._TYPE_RLE_INDEXED=9,t._TYPE_RLE_RGB=10,t._TYPE_RLE_GREY=11,t._ORIGIN_MASK=48,t._ORIGIN_SHIFT=4,t._ORIGIN_BL=0,t._ORIGIN_BR=1,t._ORIGIN_UL=2,t._ORIGIN_UR=3,t})();t.TGATools=i})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){function i(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}function r(e){return String.fromCharCode(255&e,e>>8&255,e>>16&255,e>>24&255)}var n=i("DXT1"),o=i("DXT3"),s=i("DXT5"),a=i("DX10"),l=(function(){function t(){}return t.GetDDSInfo=function(t){var i=new Int32Array(t,0,31),r=new Int32Array(t,0,35),l=1;131072&i[2]&&(l=Math.max(1,i[7]));var h=i[21],u=h===a?r[32]:0,c=e.Engine.TEXTURETYPE_UNSIGNED_INT;switch(h){case 113:c=e.Engine.TEXTURETYPE_HALF_FLOAT;break;case 116:c=e.Engine.TEXTURETYPE_FLOAT;break;case a:if(10===u){c=e.Engine.TEXTURETYPE_HALF_FLOAT;break}}return{width:i[4],height:i[3],mipmapCount:l,isFourCC:4==(4&i[20]),isRGB:64==(64&i[20]),isLuminance:131072==(131072&i[20]),isCube:512==(512&i[28]),isCompressed:h===n||h===o||h===s,dxgiFormat:u,textureType:c}},t._ToHalfFloat=function(e){t._FloatView||(t._FloatView=new Float32Array(1),t._Int32View=new Int32Array(t._FloatView.buffer)),t._FloatView[0]=e;var i=t._Int32View[0],r=i>>16&32768,n=i>>12&2047,o=i>>23&255;return o<103?r:o>142?(r|=31744,r|=(255==o?0:1)&&8388607&i):o<113?(n|=2048,r|=(n>>114-o)+(n>>113-o&1)):(r|=o-112<<10|n>>1,r+=1&n)},t._FromHalfFloat=function(e){var t=(32768&e)>>15,i=(31744&e)>>10,r=1023&e;return 0===i?(t?-1:1)*Math.pow(2,-14)*(r/Math.pow(2,10)):31==i?r?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,i-15)*(1+r/Math.pow(2,10))},t._GetHalfFloatAsFloatRGBAArrayBuffer=function(e,i,r,n,o,s){for(var a=new Float32Array(n),l=new Uint16Array(o,r),h=0,u=0;u>8&65280|e>>24&255},t.prototype.uploadLevels=function(e,i){switch(this.loadType){case t.COMPRESSED_2D:this._upload2DCompressedLevels(e,i);break;case t.TEX_2D:case t.COMPRESSED_3D:case t.TEX_3D:}},t.prototype._upload2DCompressedLevels=function(e,i){for(var r=t.HEADER_LEN+this.bytesOfKeyValueData,n=this.pixelWidth,o=this.pixelHeight,s=i?this.numberOfMipmapLevels:1,a=0;a=0;s--){var a=t[s],l=a.getParent();if(l){var h=this._debugLines[n];h||(h=[e.Vector3.Zero(),e.Vector3.Zero()],this._debugLines[n]=h),a.getAbsolutePositionToRef(this.mesh,h[0]),l.getAbsolutePositionToRef(this.mesh,h[1]),h[0].subtractInPlace(o),h[1].subtractInPlace(o),n++}}},t.prototype.update=function(){ this.autoUpdateBonesMatrices&&this.skeleton.computeAbsoluteTransforms(),void 0===this.skeleton.bones[0].length?this._getLinesForBonesNoLength(this.skeleton.bones,this.mesh.getWorldMatrix()):this._getLinesForBonesWithLength(this.skeleton.bones,this.mesh.getWorldMatrix()),this._debugMesh?e.MeshBuilder.CreateLineSystem("",{lines:this._debugLines,updatable:!0,instance:this._debugMesh},this._scene):(this._debugMesh=e.MeshBuilder.CreateLineSystem("",{lines:this._debugLines,updatable:!0,instance:null},this._scene),this._debugMesh.renderingGroupId=this.renderingGroupId),this._debugMesh.position.copyFrom(this.mesh.position),this._debugMesh.color=this.color},t.prototype.dispose=function(){this._debugMesh&&(this.isEnabled=!1,this._debugMesh.dispose(),this._debugMesh=null)},t})();t.SkeletonViewer=i})(e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var i=(function(){function t(t,i){void 0===i&&(i=1),this._xline=[e.Vector3.Zero(),e.Vector3.Zero()],this._yline=[e.Vector3.Zero(),e.Vector3.Zero()],this._zline=[e.Vector3.Zero(),e.Vector3.Zero()],this.scaleLines=1,this.scaleLines=i,this._xmesh=e.Mesh.CreateLines("xline",this._xline,t,!0),this._ymesh=e.Mesh.CreateLines("yline",this._yline,t,!0),this._zmesh=e.Mesh.CreateLines("zline",this._zline,t,!0),this._xmesh.renderingGroupId=2,this._ymesh.renderingGroupId=2,this._zmesh.renderingGroupId=2,this._xmesh.material.checkReadyOnlyOnce=!0,this._xmesh.color=new e.Color3(1,0,0),this._ymesh.material.checkReadyOnlyOnce=!0,this._ymesh.color=new e.Color3(0,1,0),this._zmesh.material.checkReadyOnlyOnce=!0,this._zmesh.color=new e.Color3(0,0,1),this.scene=t}return t.prototype.update=function(t,i,r,n){var o=this.scaleLines;this._xmesh&&this._xmesh.position.copyFrom(t),this._ymesh&&this._ymesh.position.copyFrom(t),this._zmesh&&this._zmesh.position.copyFrom(t);var s=this._xline[1];s.x=i.x*o,s.y=i.y*o,s.z=i.z*o,e.Mesh.CreateLines("",this._xline,null,!1,this._xmesh),s=this._yline[1],s.x=r.x*o,s.y=r.y*o,s.z=r.z*o,e.Mesh.CreateLines("",this._yline,null,!1,this._ymesh),s=this._zline[1],s.x=n.x*o,s.y=n.y*o,s.z=n.z*o,e.Mesh.CreateLines("",this._zline,null,!1,this._zmesh)},t.prototype.dispose=function(){this._xmesh&&this._xmesh.dispose(),this._ymesh&&this._ymesh.dispose(),this._zmesh&&this._zmesh.dispose(),this._xmesh=null,this._ymesh=null,this._zmesh=null,this.scene=null},t})();t.AxesViewer=i})(e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var i=(function(t){function i(i,r,n,o){void 0===o&&(o=1);var s=t.call(this,i,o)||this;return s.pos=e.Vector3.Zero(),s.xaxis=e.Vector3.Zero(),s.yaxis=e.Vector3.Zero(),s.zaxis=e.Vector3.Zero(),s.mesh=n,s.bone=r,s}return __extends(i,t),i.prototype.update=function(){if(this.mesh&&this.bone){var i=this.bone;i.getAbsolutePositionToRef(this.mesh,this.pos),i.getDirectionToRef(e.Axis.X,this.mesh,this.xaxis),i.getDirectionToRef(e.Axis.Y,this.mesh,this.yaxis),i.getDirectionToRef(e.Axis.Z,this.mesh,this.zaxis),t.prototype.update.call(this,this.pos,this.xaxis,this.yaxis,this.zaxis)}},i.prototype.dispose=function(){this.mesh&&(this.mesh=null,this.bone=null,t.prototype.dispose.call(this))},i})(t.AxesViewer);t.BoneAxesViewer=i})(e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this.ray=e}return t.CreateAndShow=function(e,i,r){var n=new t(e);return n.show(i,r),n},t.prototype.show=function(t,i){if(!this._renderFunction&&this.ray){var r=this.ray;this._renderFunction=this._render.bind(this),this._scene=t,this._renderPoints=[r.origin,r.origin.add(r.direction.scale(r.length))],this._renderLine=e.Mesh.CreateLines("ray",this._renderPoints,t,!0),this._renderFunction&&this._scene.registerBeforeRender(this._renderFunction)}i&&this._renderLine&&this._renderLine.color.copyFrom(i)},t.prototype.hide=function(){this._renderFunction&&this._scene&&(this._scene.unregisterBeforeRender(this._renderFunction),this._scene=null,this._renderFunction=null,this._renderLine&&(this._renderLine.dispose(),this._renderLine=null),this._renderPoints=[])},t.prototype._render=function(){var t=this.ray;if(t){var i=this._renderPoints[1],r=Math.min(t.length,1e6);i.copyFrom(t.direction),i.scaleInPlace(r),i.addInPlace(t.origin),e.Mesh.CreateLines("ray",this._renderPoints,this._scene,!0,this._renderLine)}},t.prototype.attachToMesh=function(t,i,r,n){this._attachedToMesh=t;var o=this.ray;o&&(o.direction||(o.direction=e.Vector3.Zero()),o.origin||(o.origin=e.Vector3.Zero()),n&&(o.length=n),r||(r=e.Vector3.Zero()),i||(i=new e.Vector3(0,0,-1)),this._meshSpaceDirection?(this._meshSpaceDirection.copyFrom(i),this._meshSpaceOrigin.copyFrom(r)):(this._meshSpaceDirection=i.clone(),this._meshSpaceOrigin=r.clone()),this._updateToMeshFunction||(this._updateToMeshFunction=this._updateToMesh.bind(this),this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction)),this._updateToMesh())},t.prototype.detachFromMesh=function(){this._attachedToMesh&&(this._updateToMeshFunction&&this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction),this._attachedToMesh=null,this._updateToMeshFunction=null)},t.prototype._updateToMesh=function(){var t=this.ray;if(this._attachedToMesh&&t){if(this._attachedToMesh._isDisposed)return void this.detachFromMesh();this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection,t.direction),e.Vector3.TransformCoordinatesToRef(this._meshSpaceOrigin,this._attachedToMesh.getWorldMatrix(),t.origin)}},t.prototype.dispose=function(){this.hide(),this.detachFromMesh(),this.ray=null},t})();e.RayHelper=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this.BJSINSPECTOR="undefined"!=typeof INSPECTOR?INSPECTOR:void 0,this._scene=e}return t.prototype._createInspector=function(e){void 0===e&&(e={});var t=e.popup||!1,i=e.initialTab||0,r=e.parentElement||null;this._inspector||(this.BJSINSPECTOR=this.BJSINSPECTOR||"undefined"!=typeof INSPECTOR?INSPECTOR:void 0,this._inspector=new this.BJSINSPECTOR.Inspector(this._scene,t,i,r,e.newColors))},t.prototype.isVisible=function(){return!!this._inspector},t.prototype.hide=function(){if(this._inspector){try{this._inspector.dispose()}catch(e){}this._inspector=null}},t.prototype.show=function(i){void 0===i&&(i={}),void 0===this.BJSINSPECTOR?e.Tools.LoadScript(t.InspectorURL,this._createInspector.bind(this,i)):this._createInspector(i)},t.InspectorURL="https://preview.babylonjs.com/inspector/babylon.inspector.bundle.js",t})();e.DebugLayer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var i=(function(){function t(t){this._impostors=[],this._meshes=[],this._numMeshes=0,this._scene=t||e.Engine.LastCreatedScene;var i=this._scene.getPhysicsEngine();i&&(this._physicsEnginePlugin=i.getPhysicsPlugin())}return t.prototype._updateDebugMeshes=function(){for(var e=this._physicsEnginePlugin,t=0;t0?(this._meshes[i]=this._meshes[this._numMeshes],this._impostors[i]=this._impostors[this._numMeshes],this._meshes[this._numMeshes]=null,this._impostors[this._numMeshes]=null):(this._meshes[0]=null,this._impostors[0]=null),t=!0;break}t&&0===this._numMeshes&&this._scene.unregisterBeforeRender(this._renderFunction)}},t.prototype._getDebugMaterial=function(t){return this._debugMaterial||(this._debugMaterial=new e.StandardMaterial("",t),this._debugMaterial.wireframe=!0),this._debugMaterial},t.prototype._getDebugBoxMesh=function(t){return this._debugBoxMesh||(this._debugBoxMesh=e.MeshBuilder.CreateBox("physicsBodyBoxViewMesh",{size:1},t),this._debugBoxMesh.renderingGroupId=1,this._debugBoxMesh.rotationQuaternion=e.Quaternion.Identity(),this._debugBoxMesh.material=this._getDebugMaterial(t),t.removeMesh(this._debugBoxMesh)),this._debugBoxMesh.createInstance("physicsBodyBoxViewInstance")},t.prototype._getDebugSphereMesh=function(t){return this._debugSphereMesh||(this._debugSphereMesh=e.MeshBuilder.CreateSphere("physicsBodySphereViewMesh",{diameter:1},t),this._debugSphereMesh.renderingGroupId=1,this._debugSphereMesh.rotationQuaternion=e.Quaternion.Identity(),this._debugSphereMesh.material=this._getDebugMaterial(t),t.removeMesh(this._debugSphereMesh)),this._debugSphereMesh.createInstance("physicsBodyBoxViewInstance")},t.prototype._getDebugMesh=function(t,i){var r=null;if(t.type==e.PhysicsImpostor.BoxImpostor)r=this._getDebugBoxMesh(i),t.getBoxSizeToRef(r.scaling);else if(t.type==e.PhysicsImpostor.SphereImpostor){r=this._getDebugSphereMesh(i);var n=t.getRadius();r.scaling.x=2*n,r.scaling.y=2*n,r.scaling.z=2*n}return r},t.prototype.dispose=function(){for(var e=0;e=0&&(this._targets.splice(t,1),e.onInfluenceChanged.remove(this._targetObservable.splice(t,1)[0]),this._syncActiveTargets(!0))},t.prototype.serialize=function(){var e={};e.id=this.uniqueId,e.targets=[];for(var t=0,i=this._targets;t0){this._activeTargets.push(o),this._tempInfluences[i++]=o.influence,this._supportsNormals=this._supportsNormals&&o.hasNormals,this._supportsTangents=this._supportsTangents&&o.hasTangents;var s=o.getPositions();if(!s)return void e.Tools.Error("Invalid target. Target must positions.");var a=s.length/3;if(0===this._vertexCount)this._vertexCount=a;else if(this._vertexCount!==a)return void e.Tools.Error("Incompatible target. Targets must all have the same vertices count.")}}this._influences&&this._influences.length===i||(this._influences=new Float32Array(i));for(var l=0;lthis.capacity&&this._depth>>16&65535,r=65535&e,n=t>>>16&65535,o=65535&t;return r*o+(i*o+r*n<<16>>>0)|0}),e.Matrix.prototype.multiplyToArray=i.prototype.multiplyToArraySIMD,e.Matrix.prototype.invertToRef=i.prototype.invertToRefSIMD,e.Matrix.LookAtLHToRef=i.LookAtLHToRefSIMD,e.Vector3.TransformCoordinatesToRef=t.TransformCoordinatesToRefSIMD,e.Vector3.TransformCoordinatesFromFloatsToRef=t.TransformCoordinatesFromFloatsToRefSIMD,l._isEnabled=!0)},l._isEnabled=!1,l})();e.SIMDHelper=l})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o){var s=t.call(this,i,"vrDistortionCorrection",["LensCenter","Scale","ScaleIn","HmdWarpParam"],null,o.postProcessScaleFactor,r,e.Texture.BILINEAR_SAMPLINGMODE)||this;return s._isRightEye=n,s._distortionFactors=o.distortionK,s._postProcessScaleFactor=o.postProcessScaleFactor,s._lensCenterOffset=o.lensCenterOffset,s.adaptScaleToCurrentViewport=!0,s.onSizeChangedObservable.add((function(){s.aspectRatio=.5*s.width/s.height,s._scaleIn=new e.Vector2(2,2/s.aspectRatio),s._scaleFactor=new e.Vector2(1/s._postProcessScaleFactor*.5,1/s._postProcessScaleFactor*.5*s.aspectRatio),s._lensCenter=new e.Vector2(s._isRightEye?.5-.5*s._lensCenterOffset:.5+.5*s._lensCenterOffset,.5)})),s.onApplyObservable.add((function(e){e.setFloat2("LensCenter",s._lensCenter.x,s._lensCenter.y),e.setFloat2("Scale",s._scaleFactor.x,s._scaleFactor.y),e.setFloat2("ScaleIn",s._scaleIn.x,s._scaleIn.y), e.setFloat4("HmdWarpParam",s._distortionFactors[0],s._distortionFactors[1],s._distortionFactors[2],s._distortionFactors[3])})),s}return __extends(i,t),i})(e.PostProcess);e.VRDistortionCorrectionPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r,n,o,s){var a=e.call(this,t,"anaglyph",null,["leftSampler"],i,r[1],n,o,s)||this;return a._passedProcess=r[0]._rigPostProcess,a.onApplyObservable.add((function(e){e.setTextureFromPostProcess("leftSampler",a._passedProcess)})),a}return __extends(t,e),t})(e.PostProcess);e.AnaglyphPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a){var l=t.call(this,i,"stereoscopicInterlace",["stepSize"],["camASampler"],1,r[1],o,s,a,n?"#define IS_STEREOSCOPIC_HORIZ 1":void 0)||this;return l._passedProcess=r[0]._rigPostProcess,l._stepSize=new e.Vector2(1/l.width,1/l.height),l.onSizeChangedObservable.add((function(){l._stepSize=new e.Vector2(1/l.width,1/l.height)})),l.onApplyObservable.add((function(e){e.setTextureFromPostProcess("camASampler",l._passedProcess),e.setFloat2("stepSize",l._stepSize.x,l._stepSize.y)})),l}return __extends(i,t),i})(e.PostProcess);e.StereoscopicInterlacePostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){var t=this;this._screenOrientationAngle=0,this._screenQuaternion=new e.Quaternion,this._alpha=0,this._beta=0,this._gamma=0,this._orientationChanged=function(){t._screenOrientationAngle=void 0!==window.orientation?+window.orientation:window.screen.orientation&&window.screen.orientation.angle?window.screen.orientation.angle:0,t._screenOrientationAngle=-e.Tools.ToRadians(t._screenOrientationAngle/2),t._screenQuaternion.copyFromFloats(0,Math.sin(t._screenOrientationAngle),0,Math.cos(t._screenOrientationAngle))},this._deviceOrientation=function(e){t._alpha=null!==e.alpha?e.alpha:0,t._beta=null!==e.beta?e.beta:0,t._gamma=null!==e.gamma?e.gamma:0},this._constantTranform=new e.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5)),this._orientationChanged()}return Object.defineProperty(t.prototype,"camera",{get:function(){return this._camera},set:function(t){this._camera=t,null==this._camera||this._camera.rotationQuaternion||(this._camera.rotationQuaternion=new e.Quaternion)},enumerable:!0,configurable:!0}),t.prototype.attachControl=function(e,t){window.addEventListener("orientationchange",this._orientationChanged),window.addEventListener("deviceorientation",this._deviceOrientation),this._orientationChanged()},t.prototype.detachControl=function(e){window.removeEventListener("orientationchange",this._orientationChanged),window.removeEventListener("deviceorientation",this._deviceOrientation)},t.prototype.checkInputs=function(){this._alpha&&(e.Quaternion.RotationYawPitchRollToRef(e.Tools.ToRadians(this._alpha),e.Tools.ToRadians(this._beta),-e.Tools.ToRadians(this._gamma),this.camera.rotationQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform),this._camera.rotationQuaternion.z*=-1,this._camera.rotationQuaternion.w*=-1)},t.prototype.getClassName=function(){return"FreeCameraDeviceOrientationInput"},t.prototype.getSimpleName=function(){return"deviceOrientation"},t})();e.FreeCameraDeviceOrientationInput=t,e.CameraInputTypes.FreeCameraDeviceOrientationInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this.alphaCorrection=1,this.betaCorrection=1,this.gammaCorrection=1,this._alpha=0,this._beta=0,this._gamma=0,this._dirty=!1,this._deviceOrientationHandler=this._onOrientationEvent.bind(this)}return e.prototype.attachControl=function(e,t){this.camera.attachControl(e,t),window.addEventListener("deviceorientation",this._deviceOrientationHandler)},e.prototype._onOrientationEvent=function(e){null!==e.alpha&&(this._alpha=0|+e.alpha),null!==e.beta&&(this._beta=0|+e.beta),null!==e.gamma&&(this._gamma=0|+e.gamma),this._dirty=!0},e.prototype.checkInputs=function(){this._dirty&&(this._dirty=!1,this._gamma<0&&(this._gamma=180+this._gamma),this.camera.alpha=-this._alpha/180*Math.PI%Math.PI*2,this.camera.beta=this._gamma/180*Math.PI)},e.prototype.detachControl=function(e){window.removeEventListener("deviceorientation",this._deviceOrientationHandler)},e.prototype.getClassName=function(){return"ArcRotateCameraVRDeviceOrientationInput"},e.prototype.getSimpleName=function(){return"VRDeviceOrientation"},e})();e.ArcRotateCameraVRDeviceOrientationInput=t,e.CameraInputTypes.ArcRotateCameraVRDeviceOrientationInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this.compensateDistortion=!0}return Object.defineProperty(t.prototype,"aspectRatio",{get:function(){return this.hResolution/(2*this.vResolution)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"aspectRatioFov",{get:function(){return 2*Math.atan(this.postProcessScaleFactor*this.vScreenSize/(2*this.eyeToScreenDistance))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"leftHMatrix",{get:function(){var t=this.hScreenSize/4-this.lensSeparationDistance/2,i=4*t/this.hScreenSize;return e.Matrix.Translation(i,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightHMatrix",{get:function(){var t=this.hScreenSize/4-this.lensSeparationDistance/2,i=4*t/this.hScreenSize;return e.Matrix.Translation(-i,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"leftPreViewMatrix",{get:function(){return e.Matrix.Translation(.5*this.interpupillaryDistance,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightPreViewMatrix",{get:function(){return e.Matrix.Translation(-.5*this.interpupillaryDistance,0,0)},enumerable:!0,configurable:!0}),t.GetDefault=function(){var e=new t;return e.hResolution=1280,e.vResolution=800,e.hScreenSize=.149759993,e.vScreenSize=.0935999975,e.vScreenCenter=.0467999987,e.eyeToScreenDistance=.0410000011,e.lensSeparationDistance=.063500002,e.interpupillaryDistance=.064000003,e.distortionK=[1,.219999999,.239999995,0],e.chromaAbCorrection=[.995999992,-.00400000019,1.01400006,0],e.postProcessScaleFactor=1.714605507808412,e.lensCenterOffset=.151976421,e},t})();e.VRCameraMetrics=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o){void 0===o&&(o={});var s=t.call(this,i,r,n)||this;s.webVROptions=o,s._vrDevice=null,s.rawPose=null,s._specsVersion="1.1",s._attached=!1,s._descendants=[],s.devicePosition=e.Vector3.Zero(),s.deviceScaleFactor=1,s.controllers=[],s.onControllersAttachedObservable=new e.Observable,s.onControllerMeshLoadedObservable=new e.Observable,s.rigParenting=!0,s.minZ=.1,5===arguments.length&&(s.webVROptions=arguments[4]),void 0==s.webVROptions.trackPosition&&(s.webVROptions.trackPosition=!0),void 0==s.webVROptions.controllerMeshes&&(s.webVROptions.controllerMeshes=!0),void 0==s.webVROptions.defaultLightingOnControllers&&(s.webVROptions.defaultLightingOnControllers=!0),s.rotationQuaternion=new e.Quaternion,s.deviceRotationQuaternion=new e.Quaternion,s.webVROptions&&s.webVROptions.positionScale&&(s.deviceScaleFactor=s.webVROptions.positionScale);var a=s.getEngine();return s._onVREnabled=function(e){e&&s.initControllers()},a.onVRRequestPresentComplete.add(s._onVREnabled),a.initWebVR().add((function(t){t.vrDisplay&&s._vrDevice!==t.vrDisplay&&(s._vrDevice=t.vrDisplay,s.setCameraRigMode(e.Camera.RIG_MODE_WEBVR,{parentCamera:s,vrDisplay:s._vrDevice,frameData:s._frameData,specs:s._specsVersion}),s._attached&&s.getEngine().enableVR())})),"undefined"!=typeof VRFrameData&&(s._frameData=new VRFrameData),n.onBeforeCameraRenderObservable.add((function(e){e.parent===s&&s.rigParenting&&(s._descendants=s.getDescendants(!0,(function(e){var t=s.controllers.some((function(t){return t._mesh===e})),i=-1!==s._rigCameras.indexOf(e);return!t&&!i})),s._descendants.forEach((function(t){t.parent=e})))})),n.onAfterCameraRenderObservable.add((function(e){e.parent===s&&s.rigParenting&&s._descendants.forEach((function(e){e.parent=s}))})),s}return __extends(i,t),i.prototype.dispose=function(){this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled),t.prototype.dispose.call(this)},i.prototype.getControllerByName=function(e){for(var t=0,i=this.controllers;t=2)){for(var n=!1,o=0;oi.halfWidth,t&&this._joystickPointerID<0?(this._joystickPointerID=e.pointerId,this._joystickPointerStartPos.x=e.clientX,this._joystickPointerStartPos.y=e.clientY,this._joystickPointerPos=this._joystickPointerStartPos.clone(),this._joystickPreviousPointerPos=this._joystickPointerStartPos.clone(),this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this.pressed=!0, this._touches.add(e.pointerId.toString(),e)):i._globalJoystickIndex<2&&this._action&&(this._action(),this._touches.add(e.pointerId.toString(),{x:e.clientX,y:e.clientY,prevX:e.clientX,prevY:e.clientY}))},i.prototype._onPointerMove=function(e){if(this._joystickPointerID==e.pointerId){this._joystickPointerPos.x=e.clientX,this._joystickPointerPos.y=e.clientY,this._deltaJoystickVector=this._joystickPointerPos.clone(),this._deltaJoystickVector=this._deltaJoystickVector.subtract(this._joystickPointerStartPos);var i=this.reverseLeftRight?-1:1,r=i*this._deltaJoystickVector.x/this._inversedSensibility;switch(this._axisTargetedByLeftAndRight){case t.X:this.deltaPosition.x=Math.min(1,Math.max(-1,r));break;case t.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,r));break;case t.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,r))}var n=this.reverseUpDown?1:-1,o=n*this._deltaJoystickVector.y/this._inversedSensibility;switch(this._axisTargetedByUpAndDown){case t.X:this.deltaPosition.x=Math.min(1,Math.max(-1,o));break;case t.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,o));break;case t.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,o))}}else{var s=this._touches.get(e.pointerId.toString());s&&(s.x=e.clientX,s.y=e.clientY)}},i.prototype._onPointerUp=function(e){if(this._joystickPointerID==e.pointerId)i.vjCanvasContext.clearRect(this._joystickPointerStartPos.x-64,this._joystickPointerStartPos.y-64,128,128),i.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x-42,this._joystickPreviousPointerPos.y-42,84,84),this._joystickPointerID=-1,this.pressed=!1;else{var t=this._touches.get(e.pointerId.toString());t&&i.vjCanvasContext.clearRect(t.prevX-44,t.prevY-44,88,88)}this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this._touches.remove(e.pointerId.toString())},i.prototype.setJoystickColor=function(e){this._joystickColor=e},i.prototype.setActionOnTouch=function(e){this._action=e},i.prototype.setAxisForLeftRight=function(e){switch(e){case t.X:case t.Y:case t.Z:this._axisTargetedByLeftAndRight=e;break;default:this._axisTargetedByLeftAndRight=t.X}},i.prototype.setAxisForUpDown=function(e){switch(e){case t.X:case t.Y:case t.Z:this._axisTargetedByUpAndDown=e;break;default:this._axisTargetedByUpAndDown=t.Y}},i.prototype._drawVirtualJoystick=function(){var e=this;this.pressed&&this._touches.forEach((function(t,r){r.pointerId===e._joystickPointerID?(i.vjCanvasContext.clearRect(e._joystickPointerStartPos.x-64,e._joystickPointerStartPos.y-64,128,128),i.vjCanvasContext.clearRect(e._joystickPreviousPointerPos.x-42,e._joystickPreviousPointerPos.y-42,84,84),i.vjCanvasContext.beginPath(),i.vjCanvasContext.lineWidth=6,i.vjCanvasContext.strokeStyle=e._joystickColor,i.vjCanvasContext.arc(e._joystickPointerStartPos.x,e._joystickPointerStartPos.y,40,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),i.vjCanvasContext.beginPath(),i.vjCanvasContext.strokeStyle=e._joystickColor,i.vjCanvasContext.lineWidth=2,i.vjCanvasContext.arc(e._joystickPointerStartPos.x,e._joystickPointerStartPos.y,60,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),i.vjCanvasContext.beginPath(),i.vjCanvasContext.strokeStyle=e._joystickColor,i.vjCanvasContext.arc(e._joystickPointerPos.x,e._joystickPointerPos.y,40,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),e._joystickPreviousPointerPos=e._joystickPointerPos.clone()):(i.vjCanvasContext.clearRect(r.prevX-44,r.prevY-44,88,88),i.vjCanvasContext.beginPath(),i.vjCanvasContext.fillStyle="white",i.vjCanvasContext.beginPath(),i.vjCanvasContext.strokeStyle="red",i.vjCanvasContext.lineWidth=6,i.vjCanvasContext.arc(r.x,r.y,40,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),r.prevX=r.x,r.prevY=r.y)})),requestAnimationFrame((function(){e._drawVirtualJoystick()}))},i.prototype.releaseCanvas=function(){i.vjCanvas&&(i.vjCanvas.removeEventListener("pointerdown",this._onPointerDownHandlerRef),i.vjCanvas.removeEventListener("pointermove",this._onPointerMoveHandlerRef),i.vjCanvas.removeEventListener("pointerup",this._onPointerUpHandlerRef),i.vjCanvas.removeEventListener("pointerout",this._onPointerUpHandlerRef),window.removeEventListener("resize",this._onResize),document.body.removeChild(i.vjCanvas),i.vjCanvas=null)},i._globalJoystickIndex=0,i})();e.VirtualJoystick=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addVirtualJoystick(),n}return __extends(t,e),t.prototype.getClassName=function(){return"VirtualJoysticksCamera"},t})(e.FreeCamera);e.VirtualJoysticksCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){}return t.prototype.getLeftJoystick=function(){return this._leftjoystick},t.prototype.getRightJoystick=function(){return this._rightjoystick},t.prototype.checkInputs=function(){if(this._leftjoystick){var t=this.camera,i=50*t._computeLocalCameraSpeed(),r=e.Matrix.RotationYawPitchRoll(t.rotation.y,t.rotation.x,0),n=e.Vector3.TransformCoordinates(new e.Vector3(this._leftjoystick.deltaPosition.x*i,this._leftjoystick.deltaPosition.y*i,this._leftjoystick.deltaPosition.z*i),r);t.cameraDirection=t.cameraDirection.add(n),t.cameraRotation=t.cameraRotation.addVector3(this._rightjoystick.deltaPosition),this._leftjoystick.pressed||(this._leftjoystick.deltaPosition=this._leftjoystick.deltaPosition.scale(.9)),this._rightjoystick.pressed||(this._rightjoystick.deltaPosition=this._rightjoystick.deltaPosition.scale(.9))}},t.prototype.attachControl=function(t,i){this._leftjoystick=new e.VirtualJoystick(!0),this._leftjoystick.setAxisForUpDown(e.JoystickAxis.Z),this._leftjoystick.setAxisForLeftRight(e.JoystickAxis.X),this._leftjoystick.setJoystickSensibility(.15),this._rightjoystick=new e.VirtualJoystick(!1),this._rightjoystick.setAxisForUpDown(e.JoystickAxis.X),this._rightjoystick.setAxisForLeftRight(e.JoystickAxis.Y),this._rightjoystick.reverseUpDown=!0,this._rightjoystick.setJoystickSensibility(.05),this._rightjoystick.setJoystickColor("yellow")},t.prototype.detachControl=function(e){this._leftjoystick.releaseCanvas(),this._rightjoystick.releaseCanvas()},t.prototype.getClassName=function(){return"FreeCameraVirtualJoystickInput"},t.prototype.getSimpleName=function(){return"virtualJoystick"},t})();e.FreeCameraVirtualJoystickInput=t,e.CameraInputTypes.FreeCameraVirtualJoystickInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e,t,i){this.quality=e,this.distance=t,this.optimizeMesh=i}return e})();e.SimplificationSettings=t;var i=(function(){function t(){this.running=!1,this._simplificationArray=[]}return t.prototype.addTask=function(e){this._simplificationArray.push(e)},t.prototype.executeNext=function(){var e=this._simplificationArray.pop();e?(this.running=!0,this.runSimplification(e)):this.running=!1},t.prototype.runSimplification=function(t){var i=this;if(t.parallelProcessing)t.settings.forEach((function(e){i.getSimplifier(t).simplify(e,(function(r){t.mesh.addLODLevel(e.distance,r),r.isVisible=!0,e.quality===t.settings[t.settings.length-1].quality&&t.successCallback&&t.successCallback(),i.executeNext()}))}));else{var r=this.getSimplifier(t),n=function(e,i){r.simplify(e,(function(r){t.mesh.addLODLevel(e.distance,r),r.isVisible=!0,i()}))};e.AsyncLoop.Run(t.settings.length,(function(e){n(t.settings[e.index],(function(){e.executeNext()}))}),(function(){t.successCallback&&t.successCallback(),i.executeNext()}))}},t.prototype.getSimplifier=function(e){switch(e.simplificationType){case r.QUADRATIC:default:return new l(e.mesh)}},t})();e.SimplificationQueue=i;var r;!(function(e){e[e.QUADRATIC=0]="QUADRATIC"})(r=e.SimplificationType||(e.SimplificationType={}));var n=(function(){function e(e){this.vertices=e,this.error=new Array(4),this.deleted=!1,this.isDirty=!1,this.deletePending=!1,this.borderFactor=0}return e})();e.DecimationTriangle=n;var o=(function(){function e(e,t){this.position=e,this.id=t,this.isBorder=!0,this.q=new s,this.triangleCount=0,this.triangleStart=0,this.originalOffsets=[]}return e.prototype.updatePosition=function(e){this.position.copyFrom(e)},e})();e.DecimationVertex=o;var s=(function(){function e(e){this.data=new Array(10);for(var t=0;t<10;++t)e&&e[t]?this.data[t]=e[t]:this.data[t]=0}return e.prototype.det=function(e,t,i,r,n,o,s,a,l){return this.data[e]*this.data[n]*this.data[l]+this.data[i]*this.data[r]*this.data[a]+this.data[t]*this.data[o]*this.data[s]-this.data[i]*this.data[n]*this.data[s]-this.data[e]*this.data[o]*this.data[a]-this.data[t]*this.data[r]*this.data[l]},e.prototype.addInPlace=function(e){for(var t=0;t<10;++t)this.data[t]+=e.data[t]},e.prototype.addArrayInPlace=function(e){for(var t=0;t<10;++t)this.data[t]+=e[t]},e.prototype.add=function(t){for(var i=new e,r=0;r<10;++r)i.data[r]=this.data[r]+t.data[r];return i},e.FromData=function(t,i,r,n){return new e(e.DataFromNumbers(t,i,r,n))},e.DataFromNumbers=function(e,t,i,r){return[e*e,e*t,e*i,e*r,t*t,t*i,t*r,i*i,i*r,r*r]},e})();e.QuadraticMatrix=s;var a=(function(){function e(e,t){this.vertexId=e,this.triangleId=t}return e})();e.Reference=a;var l=(function(){function t(t){this._mesh=t,this.initialized=!1,this.syncIterations=5e3,this.aggressiveness=7,this.decimationIterations=100,this.boundingBoxEpsilon=e.Epsilon}return t.prototype.simplify=function(t,i){var r=this;this.initDecimatedMesh(),e.AsyncLoop.Run(this._mesh.subMeshes.length,(function(e){r.initWithMesh(e.index,(function(){r.runDecimation(t,e.index,(function(){e.executeNext()}))}),t.optimizeMesh)}),(function(){setTimeout((function(){i(r._reconstructedMesh)}),0)}))},t.prototype.runDecimation=function(t,i,r){var n=this,o=~~(this.triangles.length*t.quality),s=0,a=this.triangles.length,l=function(t,i){setTimeout((function(){t%5==0&&n.updateMesh(0===t);for(var r=0;rl||r.deleted||r.isDirty))for(var o=0;o<3;++o)if(r.error[o]>0,f,(function(){var t=function(e){if(l){var t=h.indexStart/3+e,i=3*t,r=l[i+0],o=l[i+1],a=l[i+2],u=s.vertices[c[r-h.verticesStart]],f=s.vertices[c[o-h.verticesStart]],d=s.vertices[c[a-h.verticesStart]],p=new n([u,f,d]);p.originalOffset=i,s.triangles.push(p)}};e.AsyncLoop.SyncAsyncForLoop(h.indexCount/3,s.syncIterations,t,(function(){s.init(i)}))}))},t.prototype.init=function(t){var i=this,r=function(t){var r=i.triangles[t];r.normal=e.Vector3.Cross(r.vertices[1].position.subtract(r.vertices[0].position),r.vertices[2].position.subtract(r.vertices[0].position)).normalize();for(var n=0;n<3;n++)r.vertices[n].q.addArrayInPlace(s.DataFromNumbers(r.normal.x,r.normal.y,r.normal.z,-e.Vector3.Dot(r.normal,r.vertices[0].position)))};e.AsyncLoop.SyncAsyncForLoop(this.triangles.length,this.syncIterations,r,(function(){var r=function(e){for(var t=i.triangles[e],r=0;r<3;++r)t.error[r]=i.calculateError(t.vertices[r],t.vertices[(r+1)%3]);t.error[3]=Math.min(t.error[0],t.error[1],t.error[2])};e.AsyncLoop.SyncAsyncForLoop(i.triangles.length,i.syncIterations,r,(function(){i.initialized=!0,t()}))}))},t.prototype.reconstructMesh=function(t){var i,r=[];for(i=0;i0&&this._reconstructedMesh.setVerticesData(e.VertexBuffer.UVKind,l),h.length>0&&this._reconstructedMesh.setVerticesData(e.VertexBuffer.ColorKind,h);var b=this._mesh.subMeshes[t];t>0&&(this._reconstructedMesh.subMeshes=[],g.forEach((function(t){e.SubMesh.AddToMesh(t.materialIndex,t.verticesStart,t.verticesCount,t.indexStart,t.indexCount,t.getMesh())})),e.SubMesh.AddToMesh(b.materialIndex,m,d,_,3*r.length,this._reconstructedMesh))},t.prototype.initDecimatedMesh=function(){this._reconstructedMesh=new e.Mesh(this._mesh.name+"Decimated",this._mesh.getScene()),this._reconstructedMesh.material=this._mesh.material,this._reconstructedMesh.parent=this._mesh.parent,this._reconstructedMesh.isVisible=!1,this._reconstructedMesh.renderingGroupId=this._mesh.renderingGroupId},t.prototype.isFlipped=function(t,i,r,n,o,s){for(var a=0;a.999)return!0;var p=e.Vector3.Cross(f,d).normalize();if(n[a]=!1,e.Vector3.Dot(p,l.normal)<.2)return!0}else n[a]=!0,s.push(l)}}return!1},t.prototype.updateTriangles=function(e,t,i,r){for(var n=r,o=0;or.maximumSize&&(n.scale(.5),t=!1)}}return t},r}return __extends(t,e),t})(t);e.TextureOptimization=i;var r=(function(e){function t(t,i){void 0===t&&(t=0),void 0===i&&(i=2);var r=e.call(this,t)||this;return r.priority=t,r.maximumScale=i,r._currentScale=1,r.apply=function(e){return r._currentScale++,e.getEngine().setHardwareScalingLevel(r._currentScale),r._currentScale>=r.maximumScale},r}return __extends(t,e),t})(t);e.HardwareScalingOptimization=r;var n=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.apply=function(e){return e.shadowsEnabled=!1,!0},t}return __extends(t,e),t})(t);e.ShadowsOptimization=n;var o=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.apply=function(e){return e.postProcessesEnabled=!1,!0},t}return __extends(t,e),t})(t);e.PostProcessesOptimization=o;var s=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.apply=function(e){return e.lensFlaresEnabled=!1,!0},t}return __extends(t,e),t})(t);e.LensFlaresOptimization=s;var a=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.apply=function(e){return e.particlesEnabled=!1,!0},t}return __extends(t,e),t})(t);e.ParticlesOptimization=a;var l=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.apply=function(e){return e.renderTargetsEnabled=!1,!0},t}return __extends(t,e),t})(t);e.RenderTargetsOptimization=l;var h=(function(t){function i(){var r=null!==t&&t.apply(this,arguments)||this;return r._canBeMerged=function(t){if(!(t instanceof e.Mesh))return!1;var i=t;return!(!i.isVisible||!i.isEnabled())&&(!(i.instances.length>0)&&(!i.skeleton&&!i.hasLODLevels&&!i.parent))},r.apply=function(t,n){for(var o=t.meshes.slice(0),s=o.length,a=0;a=i.targetFrameRate)return void(n&&n());for(var s=!0,a=!0,l=0;l4&&(n.push(e.VertexBuffer.MatricesIndicesExtraKind),n.push(e.VertexBuffer.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),r.push("#define BonesPerMesh "+(o.skeleton?o.skeleton.bones.length+1:0))):r.push("#define NUM_BONE_INFLUENCERS 0"),i&&(r.push("#define INSTANCES"),n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"));var a=r.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this._scene.getEngine().createEffect("outline",n,["world","mBones","viewProjection","diffuseMatrix","offset","color","logarithmicDepthConstant"],["diffuseSampler"],a)),this._effect.isReady()},t})();e.OutlineRenderer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this.edges=new Array,this.edgesConnectedCount=0}return e})(),i=(function(){function i(e,t,i){void 0===t&&(t=.95),void 0===i&&(i=!1),this.edgesWidthScalerForOrthographic=1e3,this.edgesWidthScalerForPerspective=50,this._linesPositions=new Array,this._linesNormals=new Array,this._linesIndices=new Array,this._buffers={},this._checkVerticesInsteadOfIndices=!1,this._source=e,this._checkVerticesInsteadOfIndices=i,this._epsilon=t,this._prepareRessources(),this._generateEdgesLines()}return i.prototype._prepareRessources=function(){this._lineShader||(this._lineShader=new e.ShaderMaterial("lineShader",this._source.getScene(),"line",{attributes:["position","normal"],uniforms:["worldViewProjection","color","width","aspectRatio"]}),this._lineShader.disableDepthWrite=!0,this._lineShader.backFaceCulling=!1)},i.prototype._rebuild=function(){var t=this._buffers[e.VertexBuffer.PositionKind];t&&t._rebuild(),(t=this._buffers[e.VertexBuffer.NormalKind])&&t._rebuild();var i=this._source.getScene(),r=i.getEngine();this._ib=r.createIndexBuffer(this._linesIndices)},i.prototype.dispose=function(){var t=this._buffers[e.VertexBuffer.PositionKind];t&&(t.dispose(),this._buffers[e.VertexBuffer.PositionKind]=null),t=this._buffers[e.VertexBuffer.NormalKind],t&&(t.dispose(),this._buffers[e.VertexBuffer.NormalKind]=null),this._source.getScene().getEngine()._releaseBuffer(this._ib),this._lineShader.dispose()},i.prototype._processEdgeForAdjacencies=function(e,t,i,r,n){return e===i&&t===r||e===r&&t===i?0:e===r&&t===n||e===n&&t===r?1:e===n&&t===i||e===i&&t===n?2:-1},i.prototype._processEdgeForAdjacenciesWithVertices=function(e,t,i,r,n){return e.equalsWithEpsilon(i)&&t.equalsWithEpsilon(r)||e.equalsWithEpsilon(r)&&t.equalsWithEpsilon(i)?0:e.equalsWithEpsilon(r)&&t.equalsWithEpsilon(n)||e.equalsWithEpsilon(n)&&t.equalsWithEpsilon(r)?1:e.equalsWithEpsilon(n)&&t.equalsWithEpsilon(i)||e.equalsWithEpsilon(i)&&t.equalsWithEpsilon(n)?2:-1},i.prototype._checkEdge=function(t,i,r,n,o){var s;if(void 0===i)s=!0;else{s=e.Vector3.Dot(r[t],r[i])4&&(s.push(e.VertexBuffer.MatricesIndicesExtraKind),s.push(e.VertexBuffer.MatricesWeightsExtraKind)),o.push("#define NUM_BONE_INFLUENCERS "+a.numBoneInfluencers),o.push("#define BonesPerMesh "+(a.skeleton?a.skeleton.bones.length+1:0))):o.push("#define NUM_BONE_INFLUENCERS 0"),i&&(o.push("#define INSTANCES"),s.push("world0"),s.push("world1"),s.push("world2"),s.push("world3"));var c=o.join("\n");return this._cachedDefines!==c&&(this._cachedDefines=c,this._glowMapGenerationEffect=this._scene.getEngine().createEffect("glowMapGeneration",s,["world","mBones","viewProjection","diffuseMatrix","color","emissiveMatrix"],["diffuseSampler","emissiveSampler"],c)),this._glowMapGenerationEffect.isReady()},i.prototype.render=function(){var t=this._glowMapMergeEffect;if(t.isReady()&&this._blurTexture.isReady()){var i=this._scene.getEngine();this.onBeforeComposeObservable.notifyObservers(this),i.enableEffect(t),i.setState(!1);var r=i.getStencilBuffer(),n=i.getStencilFunction(),o=i.getStencilMask(),s=i.getStencilOperationPass(),a=i.getStencilOperationFail(),l=i.getStencilOperationDepthFail(),h=i.getAlphaMode();t.setTexture("textureSampler",this._blurTexture),i.bindBuffers(this._vertexBuffers,this._indexBuffer,t),i.setStencilOperationPass(e.Engine.REPLACE),i.setStencilOperationFail(e.Engine.KEEP),i.setStencilOperationDepthFail(e.Engine.KEEP),i.setAlphaMode(this._options.alphaBlendingMode),i.setStencilMask(0),i.setStencilBuffer(!0),i.setStencilFunctionReference(this._instanceGlowingMeshStencilReference),this.outerGlow&&(t.setFloat("offset",0),i.setStencilFunction(e.Engine.NOTEQUAL),i.draw(!0,0,6)),this.innerGlow&&(t.setFloat("offset",1),i.setStencilFunction(e.Engine.EQUAL),i.draw(!0,0,6)),i.setStencilFunction(n),i.setStencilMask(o),i.setAlphaMode(h),i.setStencilBuffer(r),i.setStencilOperationPass(s),i.setStencilOperationFail(a),i.setStencilOperationDepthFail(l),i._stencilState.reset(),this.onAfterComposeObservable.notifyObservers(this);var u=this._mainTexture.getSize();this.setMainTextureSize(),u.width===this._mainTextureDesiredSize.width&&u.height===this._mainTextureDesiredSize.height||(this.onSizeChangedObservable.notifyObservers(this),this.disposeTextureAndPostProcesses(),this.createTextureAndPostProcesses())}},i.prototype.addExcludedMesh=function(e){if(this._excludedMeshes){this._excludedMeshes[e.uniqueId]||(this._excludedMeshes[e.uniqueId]={mesh:e,beforeRender:e.onBeforeRenderObservable.add((function(e){e.getEngine().setStencilBuffer(!1)})),afterRender:e.onAfterRenderObservable.add((function(e){e.getEngine().setStencilBuffer(!0)}))})}},i.prototype.removeExcludedMesh=function(e){if(this._excludedMeshes){var t=this._excludedMeshes[e.uniqueId];t&&(t.beforeRender&&e.onBeforeRenderObservable.remove(t.beforeRender),t.afterRender&&e.onAfterRenderObservable.remove(t.afterRender)),this._excludedMeshes[e.uniqueId]=null}},i.prototype.addMesh=function(e,t,i){var r=this;if(void 0===i&&(i=!1),this._meshes){var n=this._meshes[e.uniqueId];n?n.color=t:this._meshes[e.uniqueId]={mesh:e,color:t,observerHighlight:e.onBeforeRenderObservable.add((function(e){r._excludedMeshes&&r._excludedMeshes[e.uniqueId]?r.defaultStencilReference(e):e.getScene().getEngine().setStencilFunctionReference(r._instanceGlowingMeshStencilReference)})),observerDefault:e.onAfterRenderObservable.add(this.defaultStencilReference),glowEmissiveOnly:i},this._shouldRender=!0}},i.prototype.removeMesh=function(e){if(this._meshes){var t=this._meshes[e.uniqueId];t&&(t.observerHighlight&&e.onBeforeRenderObservable.remove(t.observerHighlight),t.observerDefault&&e.onAfterRenderObservable.remove(t.observerDefault)),this._meshes[e.uniqueId]=null,this._shouldRender=!1;for(var i in this._meshes)if(i){this._shouldRender=!0;break}}},i.prototype.shouldRender=function(){return this.isEnabled&&this._shouldRender},i.prototype.setMainTextureSize=function(){this._options.mainTextureFixedSize?(this._mainTextureDesiredSize.width=this._options.mainTextureFixedSize,this._mainTextureDesiredSize.height=this._options.mainTextureFixedSize):(this._mainTextureDesiredSize.width=this._engine.getRenderWidth()*this._options.mainTextureRatio,this._mainTextureDesiredSize.height=this._engine.getRenderHeight()*this._options.mainTextureRatio,this._mainTextureDesiredSize.width=this._engine.needPOTTextures?e.Tools.GetExponentOfTwo(this._mainTextureDesiredSize.width,this._maxSize):this._mainTextureDesiredSize.width,this._mainTextureDesiredSize.height=this._engine.needPOTTextures?e.Tools.GetExponentOfTwo(this._mainTextureDesiredSize.height,this._maxSize):this._mainTextureDesiredSize.height)},i.prototype.defaultStencilReference=function(e){e.getScene().getEngine().setStencilFunctionReference(i.normalMeshStencilReference)},i.prototype.disposeTextureAndPostProcesses=function(){this._blurTexture.dispose(),this._mainTexture.dispose(),this._downSamplePostprocess.dispose(),this._horizontalBlurPostprocess.dispose(),this._verticalBlurPostprocess.dispose()},i.prototype.dispose=function(){var t=this._vertexBuffers[e.VertexBuffer.PositionKind];if(t&&(t.dispose(),this._vertexBuffers[e.VertexBuffer.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this.disposeTextureAndPostProcesses(),this._meshes){for(var i in this._meshes){var r=this._meshes[i];r&&r.mesh&&(r.observerHighlight&&r.mesh.onBeforeRenderObservable.remove(r.observerHighlight),r.observerDefault&&r.mesh.onAfterRenderObservable.remove(r.observerDefault))}this._meshes=null}if(this._excludedMeshes){for(var i in this._excludedMeshes){var r=this._excludedMeshes[i];r&&(r.beforeRender&&r.mesh.onBeforeRenderObservable.remove(r.beforeRender),r.afterRender&&r.mesh.onAfterRenderObservable.remove(r.afterRender))}this._excludedMeshes=null}var n=this._scene.highlightLayers.indexOf(this,0);n>-1&&this._scene.highlightLayers.splice(n,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderMainTextureObservable.clear(),this.onBeforeBlurObservable.clear(),this.onBeforeComposeObservable.clear(),this.onAfterComposeObservable.clear(),this.onSizeChangedObservable.clear()},i.neutralColor=new e.Color4(0,0,0,0),i.glowingMeshStencilReference=2,i.normalMeshStencilReference=1,i})();e.HighlightLayer=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t;!(function(e){e[e.INIT=0]="INIT",e[e.RUNNING=1]="RUNNING",e[e.DONE=2]="DONE",e[e.ERROR=3]="ERROR"})(t=e.AssetTaskState||(e.AssetTaskState={}));var i=(function(){function e(e){this.name=e,this.isCompleted=!1,this.taskState=t.INIT}return e.prototype.run=function(e,i,r){var n=this;this.taskState=t.RUNNING,this.runTask(e,(function(){n.onDoneCallback(i,r)}),(function(e,t){n.onErrorCallback(r,e,t)}))},e.prototype.runTask=function(e,t,i){throw new Error("runTask is not implemented")},e.prototype.onErrorCallback=function(e,i,r){this.taskState=t.ERROR,this.errorObject={message:i,exception:r},this.onError&&this.onError(this,i,r),e()},e.prototype.onDoneCallback=function(e,i){try{this.taskState=t.DONE,this.isCompleted=!0,this.onSuccess&&this.onSuccess(this),e()}catch(e){this.onErrorCallback(i,"Task is done, error executing success callback(s)",e)}},e})();e.AbstractAssetTask=i;var r=(function(){function e(e,t,i){this.remainingCount=e,this.totalCount=t,this.task=i}return e})();e.AssetsProgressEvent=r;var n=(function(t){function i(e,i,r,n){var o=t.call(this,e)||this;return o.name=e,o.meshesNames=i,o.rootUrl=r,o.sceneFilename=n,o}return __extends(i,t),i.prototype.runTask=function(t,i,r){var n=this;e.SceneLoader.ImportMesh(this.meshesNames,this.rootUrl,this.sceneFilename,t,(function(e,t,r){n.loadedMeshes=e,n.loadedParticleSystems=t,n.loadedSkeletons=r,i()}),null,(function(e,t,i){r(t,i)}))},i})(i);e.MeshAssetTask=n;var o=(function(t){function i(e,i){var r=t.call(this,e)||this;return r.name=e,r.url=i,r}return __extends(i,t),i.prototype.runTask=function(t,i,r){var n=this;e.Tools.LoadFile(this.url,(function(e){n.text=e,i()}),void 0,t.database,!1,(function(e,t){e&&r(e.status+" "+e.statusText,t)}))},i})(i);e.TextFileAssetTask=o;var s=(function(t){function i(e,i){var r=t.call(this,e)||this;return r.name=e,r.url=i,r}return __extends(i,t),i.prototype.runTask=function(t,i,r){var n=this;e.Tools.LoadFile(this.url,(function(e){n.data=e,i()}),void 0,t.database,!0,(function(e,t){e&&r(e.status+" "+e.statusText,t)}))},i})(i);e.BinaryFileAssetTask=s;var a=(function(t){function i(e,i){var r=t.call(this,e)||this;return r.name=e,r.url=i,r}return __extends(i,t),i.prototype.runTask=function(t,i,r){var n=this,o=new Image;e.Tools.SetCorsBehavior(this.url,o),o.onload=function(){n.image=o,i()},o.onerror=function(e){r("Error loading image",e)},o.src=this.url},i})(i);e.ImageAssetTask=a;var l=(function(t){function i(i,r,n,o,s){void 0===s&&(s=e.Texture.TRILINEAR_SAMPLINGMODE);var a=t.call(this,i)||this;return a.name=i,a.url=r,a.noMipmap=n,a.invertY=o,a.samplingMode=s,a}return __extends(i,t),i.prototype.runTask=function(t,i,r){var n=function(){i()},o=function(e,t){r(e,t)};this.texture=new e.Texture(this.url,t,this.noMipmap,this.invertY,this.samplingMode,n,o)},i})(i);e.TextureAssetTask=l;var h=(function(t){function i(e,i,r,n,o){var s=t.call(this,e)||this;return s.name=e,s.url=i,s.extensions=r,s.noMipmap=n,s.files=o,s}return __extends(i,t),i.prototype.runTask=function(t,i,r){var n=function(){i()},o=function(e,t){r(e,t)};this.texture=new e.CubeTexture(this.url,t,this.extensions,this.noMipmap,this.files,n,o)},i})(i);e.CubeTextureAssetTask=h;var u=(function(t){function i(e,i,r,n,o,s,a){void 0===n&&(n=!1),void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===a&&(a=!1);var l=t.call(this,e)||this;return l.name=e,l.url=i,l.size=r,l.noMipmap=n,l.generateHarmonics=o,l.useInGammaSpace=s,l.usePMREMGenerator=a,l}return __extends(i,t),i.prototype.run=function(t,i,r){var n=function(){i()},o=function(e,t){r(e,t)};this.texture=new e.HDRCubeTexture(this.url,t,this.size,this.noMipmap,this.generateHarmonics,this.useInGammaSpace,this.usePMREMGenerator,n,o)},i})(i);e.HDRCubeTextureAssetTask=u;var c=(function(){function t(t){this.tasks=new Array,this.waitingTasksCount=0,this.onTaskSuccessObservable=new e.Observable,this.onTaskErrorObservable=new e.Observable,this.onTasksDoneObservable=new e.Observable,this.onProgressObservable=new e.Observable,this.useDefaultLoadingScreen=!0,this._scene=t}return t.prototype.addMeshTask=function(e,t,i,r){var o=new n(e,t,i,r);return this.tasks.push(o),o},t.prototype.addTextFileTask=function(e,t){var i=new o(e,t);return this.tasks.push(i),i},t.prototype.addBinaryFileTask=function(e,t){var i=new s(e,t);return this.tasks.push(i),i},t.prototype.addImageTask=function(e,t){var i=new a(e,t);return this.tasks.push(i),i},t.prototype.addTextureTask=function(t,i,r,n,o){void 0===o&&(o=e.Texture.TRILINEAR_SAMPLINGMODE);var s=new l(t,i,r,n,o);return this.tasks.push(s),s},t.prototype.addCubeTextureTask=function(e,t,i,r,n){var o=new h(e,t,i,r,n);return this.tasks.push(o),o},t.prototype.addHDRCubeTextureTask=function(e,t,i,r,n,o,s){void 0===r&&(r=!1),void 0===n&&(n=!0),void 0===o&&(o=!1),void 0===s&&(s=!1);var a=new u(e,t,i,r,n,o,s);return this.tasks.push(a),a},t.prototype._decreaseWaitingTasksCount=function(t){this.waitingTasksCount--;try{this.onProgress&&this.onProgress(this.waitingTasksCount,this.tasks.length,t),this.onProgressObservable.notifyObservers(new r(this.waitingTasksCount,this.tasks.length,t))}catch(t){e.Tools.Error("Error running progress callbacks."),console.log(t)}if(0===this.waitingTasksCount){try{this.onFinish&&this.onFinish(this.tasks),this.onTasksDoneObservable.notifyObservers(this.tasks)}catch(t){e.Tools.Error("Error running tasks-done callbacks."),console.log(t)}this._scene.getEngine().hideLoadingUI()}},t.prototype._runTask=function(e){var t=this,i=function(){try{t.onTaskSuccess&&t.onTaskSuccess(e),t.onTaskSuccessObservable.notifyObservers(e),t._decreaseWaitingTasksCount(e)}catch(e){r("Error executing task success callbacks",e)}},r=function(i,r){e.errorObject=e.errorObject||{message:i,exception:r},t.onTaskError&&t.onTaskError(e),t.onTaskErrorObservable.notifyObservers(e),t._decreaseWaitingTasksCount(e)};e.run(this._scene,i,r)},t.prototype.reset=function(){return this.tasks=new Array,this},t.prototype.load=function(){if(this.waitingTasksCount=this.tasks.length,0===this.waitingTasksCount)return this.onFinish&&this.onFinish(this.tasks),this.onTasksDoneObservable.notifyObservers(this.tasks),this;this.useDefaultLoadingScreen&&this._scene.getEngine().displayLoadingUI();for(var e=0;ec.upperRadiusLimit?c.upperRadiusLimit:u),u):0},t.prototype._maintainCameraAboveGround=function(){var i=this;if(!(this._elevationReturnTime<0)){var r=e.Tools.Now-this._lastInteractionTime,n=.5*Math.PI-this._defaultElevation,o=.5*Math.PI;if(this._attachedCamera&&!this._betaIsAnimating&&this._attachedCamera.beta>o&&r>=this._elevationReturnWaitTime){this._betaIsAnimating=!0,this.stopAllAnimations(),this._betaTransition||(this._betaTransition=e.Animation.CreateAnimation("beta",e.Animation.ANIMATIONTYPE_FLOAT,60,t.EasingFunction));var s=e.Animation.TransitionTo("beta",n,this._attachedCamera,this._attachedCamera.getScene(),60,this._betaTransition,this._elevationReturnTime,(function(){i._clearAnimationLocks(),i.stopAllAnimations()}));s&&this._animatables.push(s)}}},t.prototype._getFrustumSlope=function(){var t=this._attachedCamera;if(!t)return e.Vector2.Zero();var i=t.getScene().getEngine(),r=i.getAspectRatio(t),n=Math.tan(t.fov/2),o=n*r;return new e.Vector2(o,n)},t.prototype._clearAnimationLocks=function(){this._betaIsAnimating=!1},t.prototype._applyUserInteraction=function(){this.isUserIsMoving&&(this._lastInteractionTime=e.Tools.Now,this.stopAllAnimations(),this._clearAnimationLocks())},t.prototype.stopAllAnimations=function(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0]&&(this._animatables[0].onAnimationEnd=null,this._animatables[0].stop()),this._animatables.shift()},Object.defineProperty(t.prototype,"isUserIsMoving",{get:function(){return!!this._attachedCamera&&(0!==this._attachedCamera.inertialAlphaOffset||0!==this._attachedCamera.inertialBetaOffset||0!==this._attachedCamera.inertialRadiusOffset||0!==this._attachedCamera.inertialPanningX||0!==this._attachedCamera.inertialPanningY||this._isPointerDown)},enumerable:!0,configurable:!0}),t.EasingFunction=new e.ExponentialEase,t.EasingMode=e.EasingFunction.EASINGMODE_EASEINOUT,t.IgnoreBoundsSizeMode=0,t.FitFrustumSidesMode=1,t})();e.FramingBehavior=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this.transitionDuration=450,this.lowerRadiusTransitionRange=2,this.upperRadiusTransitionRange=-2,this._autoTransitionRange=!1,this._radiusIsAnimating=!1,this._radiusBounceTransition=null,this._animatables=new Array}return Object.defineProperty(t.prototype,"name",{get:function(){return"Bouncing"},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"autoTransitionRange",{get:function(){return this._autoTransitionRange},set:function(e){var t=this;if(this._autoTransitionRange!==e){this._autoTransitionRange=e;var i=this._attachedCamera;i&&(e?this._onMeshTargetChangedObserver=i.onMeshTargetChangedObservable.add((function(e){if(e){e.computeWorldMatrix(!0);var i=e.getBoundingInfo().diagonalLength;t.lowerRadiusTransitionRange=.05*i,t.upperRadiusTransitionRange=.05*i}})):this._onMeshTargetChangedObserver&&i.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver))}},enumerable:!0,configurable:!0}),t.prototype.init=function(){},t.prototype.attach=function(e){var t=this;this._attachedCamera=e,this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((function(){t._attachedCamera&&(t._isRadiusAtLimit(t._attachedCamera.lowerRadiusLimit)&&t._applyBoundRadiusAnimation(t.lowerRadiusTransitionRange),t._isRadiusAtLimit(t._attachedCamera.upperRadiusLimit)&&t._applyBoundRadiusAnimation(t.upperRadiusTransitionRange))}))},t.prototype.detach=function(){this._attachedCamera&&(this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null)},t.prototype._isRadiusAtLimit=function(e){return!!this._attachedCamera&&(this._attachedCamera.radius===e&&!this._radiusIsAnimating)},t.prototype._applyBoundRadiusAnimation=function(i){var r=this;if(this._attachedCamera){this._radiusBounceTransition||(t.EasingFunction.setEasingMode(t.EasingMode),this._radiusBounceTransition=e.Animation.CreateAnimation("radius",e.Animation.ANIMATIONTYPE_FLOAT,60,t.EasingFunction)),this._cachedWheelPrecision=this._attachedCamera.wheelPrecision,this._attachedCamera.wheelPrecision=1/0,this._attachedCamera.inertialRadiusOffset=0,this.stopAllAnimations(),this._radiusIsAnimating=!0;var n=e.Animation.TransitionTo("radius",this._attachedCamera.radius+i,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusBounceTransition,this.transitionDuration,(function(){return r._clearAnimationLocks()}));n&&this._animatables.push(n)}},t.prototype._clearAnimationLocks=function(){this._radiusIsAnimating=!1,this._attachedCamera&&(this._attachedCamera.wheelPrecision=this._cachedWheelPrecision)},t.prototype.stopAllAnimations=function(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0].onAnimationEnd=null,this._animatables[0].stop(),this._animatables.shift()},t.EasingFunction=new e.BackEase(.3),t.EasingMode=e.EasingFunction.EASINGMODE_EASEOUT,t})();e.BouncingBehavior=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._zoomStopsAnimation=!1,this._idleRotationSpeed=.05,this._idleRotationWaitTime=2e3,this._idleRotationSpinupTime=2e3,this._isPointerDown=!1,this._lastFrameTime=null,this._lastInteractionTime=-1/0,this._cameraRotationSpeed=0,this._lastFrameRadius=0}return Object.defineProperty(t.prototype,"name",{get:function(){return"AutoRotation"},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"zoomStopsAnimation",{get:function(){return this._zoomStopsAnimation},set:function(e){this._zoomStopsAnimation=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"idleRotationSpeed",{get:function(){return this._idleRotationSpeed},set:function(e){this._idleRotationSpeed=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"idleRotationWaitTime",{get:function(){return this._idleRotationWaitTime},set:function(e){this._idleRotationWaitTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"idleRotationSpinupTime",{get:function(){return this._idleRotationSpinupTime},set:function(e){this._idleRotationSpinupTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rotationInProgress",{get:function(){return Math.abs(this._cameraRotationSpeed)>0},enumerable:!0,configurable:!0}),t.prototype.init=function(){},t.prototype.attach=function(t){var i=this;this._attachedCamera=t;var r=this._attachedCamera.getScene();this._onPrePointerObservableObserver=r.onPrePointerObservable.add((function(t){if(t.type===e.PointerEventTypes.POINTERDOWN)return void(i._isPointerDown=!0);t.type===e.PointerEventTypes.POINTERUP&&(i._isPointerDown=!1)})),this._onAfterCheckInputsObserver=t.onAfterCheckInputsObservable.add((function(){var t=e.Tools.Now,r=0;null!=i._lastFrameTime&&(r=t-i._lastFrameTime),i._lastFrameTime=t,i._applyUserInteraction();var n=t-i._lastInteractionTime-i._idleRotationWaitTime,o=Math.max(Math.min(n/i._idleRotationSpinupTime,1),0);i._cameraRotationSpeed=i._idleRotationSpeed*o,i._attachedCamera&&(i._attachedCamera.alpha-=i._cameraRotationSpeed*(r/1e3))}))},t.prototype.detach=function(){if(this._attachedCamera){var e=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._attachedCamera=null}},t.prototype._userIsZooming=function(){return!!this._attachedCamera&&0!==this._attachedCamera.inertialRadiusOffset},t.prototype._shouldAnimationStopForInteraction=function(){if(!this._attachedCamera)return!1;var e=!1;return this._lastFrameRadius===this._attachedCamera.radius&&0!==this._attachedCamera.inertialRadiusOffset&&(e=!0),this._lastFrameRadius=this._attachedCamera.radius,this._zoomStopsAnimation?e:this._userIsZooming()},t.prototype._applyUserInteraction=function(){this._userIsMoving()&&!this._shouldAnimationStopForInteraction()&&(this._lastInteractionTime=e.Tools.Now)},t.prototype._userIsMoving=function(){return!!this._attachedCamera&&(0!==this._attachedCamera.inertialAlphaOffset||0!==this._attachedCamera.inertialBetaOffset||0!==this._attachedCamera.inertialRadiusOffset||0!==this._attachedCamera.inertialPanningX||0!==this._attachedCamera.inertialPanningY||this._isPointerDown)},t})();e.AutoRotationBehavior=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this.renderWidth=512,this.renderHeight=256,this.textureSize=512}return e})();e.NullEngineOptions=t;var i=(function(i){function r(r){void 0===r&&(r=new t);var n=i.call(this,null)||this;return n._options=r,n._caps=new e.EngineCapabilities,n._caps.maxTexturesImageUnits=16,n._caps.maxVertexTextureImageUnits=16,n._caps.maxTextureSize=512,n._caps.maxCubemapTextureSize=512,n._caps.maxRenderTextureSize=512,n._caps.maxVertexAttribs=16,n._caps.maxVaryingVectors=16,n._caps.maxFragmentUniformVectors=16,n._caps.maxVertexUniformVectors=16,n._caps.standardDerivatives=!1,n._caps.astc=null,n._caps.s3tc=null,n._caps.pvrtc=null,n._caps.etc1=null,n._caps.etc2=null,n._caps.textureAnisotropicFilterExtension=null,n._caps.maxAnisotropy=0,n._caps.uintIndices=!1,n._caps.fragmentDepthSupported=!1,n._caps.highPrecisionShaderSupported=!0,n._caps.colorBufferFloat=!1,n._caps.textureFloat=!1,n._caps.textureFloatLinearFiltering=!1,n._caps.textureFloatRender=!1,n._caps.textureHalfFloat=!1,n._caps.textureHalfFloatLinearFiltering=!1,n._caps.textureHalfFloatRender=!1,n._caps.textureLOD=!1,n._caps.drawBuffersExtension=!1,n._caps.depthTextureExtension=!1,n._caps.vertexArrayObject=!1,n._caps.instancedArrays=!1,e.Tools.Log("Babylon.js null engine (v"+e.Engine.Version+") launched"),"undefined"==typeof URL&&(URL={createObjectURL:function(){},revokeObjectURL:function(){}}),"undefined"==typeof Blob&&(Blob=function(){}),n}return __extends(r,i),r.prototype.createVertexBuffer=function(e){return{capacity:0,references:1,is32Bits:!1}},r.prototype.createIndexBuffer=function(e){return{capacity:0,references:1,is32Bits:!1}},r.prototype.clear=function(e,t,i,r){void 0===r&&(r=!1)},r.prototype.getRenderWidth=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.width:this._options.renderWidth},r.prototype.getRenderHeight=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.height:this._options.renderHeight},r.prototype.setViewport=function(e,t,i){this._cachedViewport=e},r.prototype.createShaderProgram=function(e,t,i,r){return{transformFeedback:null,__SPECTOR_rebuildProgram:null}},r.prototype.getUniforms=function(e,t){return[]},r.prototype.getAttributes=function(e,t){return[]},r.prototype.bindSamplers=function(e){this._currentEffect=null},r.prototype.enableEffect=function(e){this._currentEffect=e,e.onBind&&e.onBind(e),e.onBindObservable.notifyObservers(e)},r.prototype.setState=function(e,t,i,r){void 0===t&&(t=0),void 0===r&&(r=!1)},r.prototype.setIntArray=function(e,t){},r.prototype.setIntArray2=function(e,t){},r.prototype.setIntArray3=function(e,t){},r.prototype.setIntArray4=function(e,t){},r.prototype.setFloatArray=function(e,t){},r.prototype.setFloatArray2=function(e,t){},r.prototype.setFloatArray3=function(e,t){},r.prototype.setFloatArray4=function(e,t){},r.prototype.setArray=function(e,t){},r.prototype.setArray2=function(e,t){},r.prototype.setArray3=function(e,t){},r.prototype.setArray4=function(e,t){},r.prototype.setMatrices=function(e,t){},r.prototype.setMatrix=function(e,t){},r.prototype.setMatrix3x3=function(e,t){},r.prototype.setMatrix2x2=function(e,t){},r.prototype.setFloat=function(e,t){},r.prototype.setFloat2=function(e,t,i){},r.prototype.setFloat3=function(e,t,i,r){},r.prototype.setBool=function(e,t){},r.prototype.setFloat4=function(e,t,i,r,n){},r.prototype.setColor3=function(e,t){},r.prototype.setColor4=function(e,t,i){},r.prototype.setAlphaMode=function(t,i){void 0===i&&(i=!1),this._alphaMode!==t&&(this._alphaState.alphaBlend=t!==e.Engine.ALPHA_DISABLE,i||this.setDepthWrite(t===e.Engine.ALPHA_DISABLE),this._alphaMode=t)},r.prototype.bindBuffers=function(e,t,i){},r.prototype.wipeCaches=function(e){this.preventCacheWipeBetweenFrames||(this.resetTextureCache(),this._currentEffect=null,e&&(this._currentProgram=null,this._stencilState.reset(),this._depthCullingState.reset(),this.setDepthFunctionToLessOrEqual(),this._alphaState.reset()),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._cachedEffectForVertexBuffers=null)},r.prototype.draw=function(e,t,i,r){},r.prototype._createTexture=function(){return{}},r.prototype.createTexture=function(t,i,r,n,o,s,a,l,h,u){void 0===o&&(o=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===s&&(s=null),void 0===a&&(a=null),void 0===l&&(l=null);var c=new e.InternalTexture(this,e.InternalTexture.DATASOURCE_URL),f=String(t);return c.url=f,c.generateMipMaps=!i,c.samplingMode=o,c.invertY=r,c.baseWidth=this._options.textureSize,c.baseHeight=this._options.textureSize,c.width=this._options.textureSize,c.height=this._options.textureSize,u&&(c.format=u),c.isReady=!0,s&&s(),c},r.prototype.createRenderTargetTexture=function(t,i){var r=new e.RenderTargetCreationOptions;void 0!==i&&"object"==typeof i?(r.generateMipMaps=i.generateMipMaps,r.generateDepthBuffer=void 0===i.generateDepthBuffer||i.generateDepthBuffer,r.generateStencilBuffer=r.generateDepthBuffer&&i.generateStencilBuffer,r.type=void 0===i.type?e.Engine.TEXTURETYPE_UNSIGNED_INT:i.type,r.samplingMode=void 0===i.samplingMode?e.Texture.TRILINEAR_SAMPLINGMODE:i.samplingMode):(r.generateMipMaps=i,r.generateDepthBuffer=!0,r.generateStencilBuffer=!1,r.type=e.Engine.TEXTURETYPE_UNSIGNED_INT,r.samplingMode=e.Texture.TRILINEAR_SAMPLINGMODE);var n=new e.InternalTexture(this,e.InternalTexture.DATASOURCE_RENDERTARGET),o=t.width||t,s=t.height||t;return n._depthStencilBuffer={},n._framebuffer={},n.baseWidth=o,n.baseHeight=s,n.width=o,n.height=s,n.isReady=!0,n.samples=1,n.generateMipMaps=!!r.generateMipMaps,n.samplingMode=r.samplingMode,n.type=r.type,n._generateDepthBuffer=r.generateDepthBuffer,n._generateStencilBuffer=!!r.generateStencilBuffer,n},r.prototype.updateTextureSamplingMode=function(e,t){t.samplingMode=e},r.prototype.bindFramebuffer=function(e,t,i,r,n){this._currentRenderTarget&&this.unBindFramebuffer(this._currentRenderTarget),this._currentRenderTarget=e,this._currentFramebuffer=e._MSAAFramebuffer?e._MSAAFramebuffer:e._framebuffer,this._cachedViewport&&!n&&this.setViewport(this._cachedViewport,i,r)},r.prototype.unBindFramebuffer=function(e,t,i){void 0===t&&(t=!1),this._currentRenderTarget=null,i&&(e._MSAAFramebuffer&&(this._currentFramebuffer=e._framebuffer),i()),this._currentFramebuffer=null},r.prototype.createDynamicVertexBuffer=function(e){return{capacity:1,references:1,is32Bits:!1}},r.prototype.updateDynamicIndexBuffer=function(e,t,i){void 0===i&&(i=0)},r.prototype.updateDynamicVertexBuffer=function(e,t,i,r){},r.prototype._bindTextureDirectly=function(e,t){this._activeTexturesCache[this._activeTextureChannel]!==t&&(this._activeTexturesCache[this._activeTextureChannel]=t)},r.prototype._bindTexture=function(e,t){e<0||this._bindTextureDirectly(0,t)},r.prototype._releaseBuffer=function(e){return 0===--e.references},r})(e.Engine);e.NullEngine=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t){this.engine=t,this._captureGPUFrameTime=!1,this._gpuFrameTime=new e.PerfCounter,this._captureShaderCompilationTime=!1,this._shaderCompilationTime=new e.PerfCounter,this._onBeginFrameObserver=null,this._onEndFrameObserver=null,this._onBeforeShaderCompilationObserver=null,this._onAfterShaderCompilationObserver=null}return Object.defineProperty(t.prototype,"gpuFrameTimeCounter",{get:function(){return this._gpuFrameTime},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"captureGPUFrameTime",{get:function(){return this._captureGPUFrameTime},set:function(e){var t=this;e!==this._captureGPUFrameTime&&(this._captureGPUFrameTime=e,e?(this._onBeginFrameObserver=this.engine.onBeginFrameObservable.add((function(){t._gpuFrameTimeToken||(t._gpuFrameTimeToken=t.engine.startTimeQuery())})),this._onEndFrameObserver=this.engine.onEndFrameObservable.add((function(){if(t._gpuFrameTimeToken){var e=t.engine.endTimeQuery(t._gpuFrameTimeToken);e>-1&&(t._gpuFrameTimeToken=null,t._gpuFrameTime.fetchNewFrame(),t._gpuFrameTime.addCount(e,!0))}}))):(this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver),this._onBeginFrameObserver=null,this.engine.onEndFrameObservable.remove(this._onEndFrameObserver),this._onEndFrameObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shaderCompilationTimeCounter",{get:function(){return this._shaderCompilationTime},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"captureShaderCompilationTime",{get:function(){return this._captureShaderCompilationTime},set:function(e){var t=this;e!==this._captureShaderCompilationTime&&(this._captureShaderCompilationTime=e,e?(this._onBeforeShaderCompilationObserver=this.engine.onBeforeShaderCompilationObservable.add((function(){t._shaderCompilationTime.fetchNewFrame(),t._shaderCompilationTime.beginMonitoring()})),this._onAfterShaderCompilationObserver=this.engine.onAfterShaderCompilationObservable.add((function(){t._shaderCompilationTime.endMonitoring()}))):(this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver),this._onBeforeShaderCompilationObserver=null,this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver),this._onAfterShaderCompilationObserver=null))},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver),this._onBeginFrameObserver=null,this.engine.onEndFrameObservable.remove(this._onEndFrameObserver),this._onEndFrameObserver=null,this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver),this._onBeforeShaderCompilationObserver=null,this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver),this._onAfterShaderCompilationObserver=null,this.engine=null},t})();e.EngineInstrumentation=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t){var i=this;this.scene=t,this._captureActiveMeshesEvaluationTime=!1,this._activeMeshesEvaluationTime=new e.PerfCounter,this._captureRenderTargetsRenderTime=!1,this._renderTargetsRenderTime=new e.PerfCounter,this._captureFrameTime=!1,this._frameTime=new e.PerfCounter,this._captureRenderTime=!1,this._renderTime=new e.PerfCounter,this._captureInterFrameTime=!1,this._interFrameTime=new e.PerfCounter,this._captureParticlesRenderTime=!1,this._particlesRenderTime=new e.PerfCounter,this._captureSpritesRenderTime=!1,this._spritesRenderTime=new e.PerfCounter,this._capturePhysicsTime=!1,this._physicsTime=new e.PerfCounter,this._captureAnimationsTime=!1,this._animationsTime=new e.PerfCounter,this._onBeforeActiveMeshesEvaluationObserver=null,this._onAfterActiveMeshesEvaluationObserver=null,this._onBeforeRenderTargetsRenderObserver=null,this._onAfterRenderTargetsRenderObserver=null,this._onAfterRenderObserver=null,this._onBeforeDrawPhaseObserver=null,this._onAfterDrawPhaseObserver=null,this._onBeforeAnimationsObserver=null,this._onBeforeParticlesRenderingObserver=null,this._onAfterParticlesRenderingObserver=null,this._onBeforeSpritesRenderingObserver=null,this._onAfterSpritesRenderingObserver=null,this._onBeforePhysicsObserver=null,this._onAfterPhysicsObserver=null,this._onAfterAnimationsObserver=null,this._onBeforeAnimationsObserver=t.onBeforeAnimationsObservable.add((function(){i._captureActiveMeshesEvaluationTime&&i._activeMeshesEvaluationTime.fetchNewFrame(),i._captureRenderTargetsRenderTime&&i._renderTargetsRenderTime.fetchNewFrame(),i._captureFrameTime&&(e.Tools.StartPerformanceCounter("Scene rendering"),i._frameTime.beginMonitoring()),i._captureInterFrameTime&&i._interFrameTime.endMonitoring(),i._captureParticlesRenderTime&&i._particlesRenderTime.fetchNewFrame(),i._captureSpritesRenderTime&&i._spritesRenderTime.fetchNewFrame(),i._captureAnimationsTime&&i._animationsTime.beginMonitoring(),i.scene.getEngine()._drawCalls.fetchNewFrame()})),this._onAfterRenderObserver=t.onAfterRenderObservable.add((function(){i._captureFrameTime&&(e.Tools.EndPerformanceCounter("Scene rendering"),i._frameTime.endMonitoring()),i._captureRenderTime&&i._renderTime.endMonitoring(!1),i._captureInterFrameTime&&i._interFrameTime.beginMonitoring()}))}return Object.defineProperty(t.prototype,"activeMeshesEvaluationTimeCounter",{get:function(){return this._activeMeshesEvaluationTime},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"captureActiveMeshesEvaluationTime",{get:function(){return this._captureActiveMeshesEvaluationTime},set:function(t){var i=this;t!==this._captureActiveMeshesEvaluationTime&&(this._captureActiveMeshesEvaluationTime=t,t?(this._onBeforeActiveMeshesEvaluationObserver=this.scene.onBeforeActiveMeshesEvaluationObservable.add((function(){e.Tools.StartPerformanceCounter("Active meshes evaluation"),i._activeMeshesEvaluationTime.beginMonitoring()})),this._onAfterActiveMeshesEvaluationObserver=this.scene.onAfterActiveMeshesEvaluationObservable.add((function(){e.Tools.EndPerformanceCounter("Active meshes evaluation"),i._activeMeshesEvaluationTime.endMonitoring()}))):(this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver),this._onBeforeActiveMeshesEvaluationObserver=null,this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver),this._onAfterActiveMeshesEvaluationObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"renderTargetsRenderTimeCounter",{get:function(){return this._renderTargetsRenderTime},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"captureRenderTargetsRenderTime",{get:function(){return this._captureRenderTargetsRenderTime},set:function(t){var i=this;t!==this._captureRenderTargetsRenderTime&&(this._captureRenderTargetsRenderTime=t,t?(this._onBeforeRenderTargetsRenderObserver=this.scene.OnBeforeRenderTargetsRenderObservable.add((function(){e.Tools.StartPerformanceCounter("Render targets rendering"),i._renderTargetsRenderTime.beginMonitoring()})),this._onAfterRenderTargetsRenderObserver=this.scene.OnAfterRenderTargetsRenderObservable.add((function(){e.Tools.EndPerformanceCounter("Render targets rendering"),i._renderTargetsRenderTime.endMonitoring(!1)}))):(this.scene.OnBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver),this._onBeforeRenderTargetsRenderObserver=null,this.scene.OnAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver),this._onAfterRenderTargetsRenderObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"particlesRenderTimeCounter",{get:function(){return this._particlesRenderTime},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"captureParticlesRenderTime",{get:function(){return this._captureParticlesRenderTime},set:function(t){var i=this;t!==this._captureParticlesRenderTime&&(this._captureParticlesRenderTime=t,t?(this._onBeforeParticlesRenderingObserver=this.scene.onBeforeParticlesRenderingObservable.add((function(){e.Tools.StartPerformanceCounter("Particles"),i._particlesRenderTime.beginMonitoring()})),this._onAfterParticlesRenderingObserver=this.scene.onAfterParticlesRenderingObservable.add((function(){e.Tools.EndPerformanceCounter("Particles"),i._particlesRenderTime.endMonitoring(!1)}))):(this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver),this._onBeforeParticlesRenderingObserver=null,this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver),this._onAfterParticlesRenderingObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"spritesRenderTimeCounter",{get:function(){return this._spritesRenderTime},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"captureSpritesRenderTime",{get:function(){return this._captureSpritesRenderTime},set:function(t){var i=this;t!==this._captureSpritesRenderTime&&(this._captureSpritesRenderTime=t,t?(this._onBeforeSpritesRenderingObserver=this.scene.onBeforeSpritesRenderingObservable.add((function(){e.Tools.StartPerformanceCounter("Sprites"),i._spritesRenderTime.beginMonitoring()})),this._onAfterSpritesRenderingObserver=this.scene.onAfterSpritesRenderingObservable.add((function(){e.Tools.EndPerformanceCounter("Sprites"),i._spritesRenderTime.endMonitoring(!1)}))):(this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver),this._onBeforeSpritesRenderingObserver=null,this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver),this._onAfterSpritesRenderingObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"physicsTimeCounter",{get:function(){return this._physicsTime},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"capturePhysicsTime",{get:function(){return this._capturePhysicsTime},set:function(t){var i=this;t!==this._capturePhysicsTime&&(this._capturePhysicsTime=t,t?(this._onBeforePhysicsObserver=this.scene.onBeforePhysicsObservable.add((function(){e.Tools.StartPerformanceCounter("Physics"),i._physicsTime.beginMonitoring()})),this._onAfterPhysicsObserver=this.scene.onAfterPhysicsObservable.add((function(){e.Tools.EndPerformanceCounter("Physics"),i._physicsTime.endMonitoring()}))):(this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver),this._onBeforePhysicsObserver=null,this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver),this._onAfterPhysicsObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"animationsTimeCounter",{get:function(){return this._animationsTime},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"captureAnimationsTime",{get:function(){return this._captureAnimationsTime},set:function(e){var t=this;e!==this._captureAnimationsTime&&(this._captureAnimationsTime=e,e?this._onAfterAnimationsObserver=this.scene.onAfterAnimationsObservable.add((function(){t._animationsTime.endMonitoring()})):(this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver),this._onAfterAnimationsObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"frameTimeCounter",{get:function(){return this._frameTime},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"captureFrameTime",{get:function(){return this._captureFrameTime},set:function(e){this._captureFrameTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"interFrameTimeCounter",{get:function(){return this._interFrameTime}, enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"captureInterFrameTime",{get:function(){return this._captureInterFrameTime},set:function(e){this._captureInterFrameTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"renderTimeCounter",{get:function(){return this._renderTime},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"captureRenderTime",{get:function(){return this._captureRenderTime},set:function(t){var i=this;t!==this._captureRenderTime&&(this._captureRenderTime=t,t?(this._onBeforeDrawPhaseObserver=this.scene.onBeforeDrawPhaseObservable.add((function(){i._renderTime.beginMonitoring(),e.Tools.StartPerformanceCounter("Main render")})),this._onAfterDrawPhaseObserver=this.scene.onAfterDrawPhaseObservable.add((function(){i._renderTime.endMonitoring(!1),e.Tools.EndPerformanceCounter("Main render")}))):(this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver),this._onBeforeDrawPhaseObserver=null,this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver),this._onAfterDrawPhaseObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"drawCallsCounter",{get:function(){return this.scene.getEngine()._drawCalls},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=null,this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver),this._onBeforeActiveMeshesEvaluationObserver=null,this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver),this._onAfterActiveMeshesEvaluationObserver=null,this.scene.OnBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver),this._onBeforeRenderTargetsRenderObserver=null,this.scene.OnAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver),this._onAfterRenderTargetsRenderObserver=null,this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver),this._onBeforeAnimationsObserver=null,this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver),this._onBeforeParticlesRenderingObserver=null,this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver),this._onAfterParticlesRenderingObserver=null,this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver),this._onBeforeSpritesRenderingObserver=null,this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver),this._onAfterSpritesRenderingObserver=null,this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver),this._onBeforeDrawPhaseObserver=null,this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver),this._onAfterDrawPhaseObserver=null,this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver),this._onBeforePhysicsObserver=null,this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver),this._onAfterPhysicsObserver=null,this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver),this._onAfterAnimationsObserver=null,this.scene=null},t})();e.SceneInstrumentation=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this._timeElapsedQueryEnded=!1}return e})();e._TimeToken=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(){var t=e.call(this)||this;return t.DIFFUSE=!1,t.DIFFUSEDIRECTUV=0,t.GAMMADIFFUSE=!1,t.DIFFUSEHASALPHA=!1,t.OPACITYFRESNEL=!1,t.REFLECTIONBLUR=!1,t.REFLECTIONFRESNEL=!1,t.REFLECTIONFALLOFF=!1,t.TEXTURELODSUPPORT=!1,t.PREMULTIPLYALPHA=!1,t.USERGBCOLOR=!1,t.NOISE=!1,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.COLORGRADING3D=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.EXPOSURE=!1,t.REFLECTION=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.REFLECTIONMAP_OPPOSITEZ=!1,t.LODINREFLECTIONALPHA=!1,t.GAMMAREFLECTION=!1,t.MAINUV1=!1,t.MAINUV2=!1,t.UV1=!1,t.UV2=!1,t.CLIPPLANE=!1,t.POINTSIZE=!1,t.FOG=!1,t.NORMAL=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.INSTANCES=!1,t.SHADOWFLOAT=!1,t.rebuild(),t}return __extends(t,e),t})(e.MaterialDefines),i=(function(i){function r(t,r){var n=i.call(this,t,r)||this;return n.primaryColor=e.Color3.White(),n.primaryLevel=1,n.secondaryColor=e.Color3.Gray(),n.secondaryLevel=1,n.tertiaryColor=e.Color3.Black(),n.tertiaryLevel=1,n.reflectionTexture=null,n.reflectionBlur=0,n.diffuseTexture=null,n._shadowLights=null,n.shadowLights=null,n.shadowBlurScale=1,n.shadowLevel=0,n.sceneCenter=e.Vector3.Zero(),n.opacityFresnel=!0,n.reflectionFresnel=!1,n.reflectionFalloffDistance=0,n.reflectionAmount=1,n.reflectionReflectance0=.05,n.reflectionReflectance90=.5,n.useRGBColor=!0,n.enableNoise=!1,n._maxSimultaneousLights=4,n.maxSimultaneousLights=4,n._imageProcessingObserver=null,n._renderTargets=new e.SmartArray(16),n._reflectionControls=e.Vector4.Zero(),n._attachImageProcessingConfiguration(null),n.getRenderTargetTextures=function(){return n._renderTargets.reset(),n._diffuseTexture&&n._diffuseTexture.isRenderTarget&&n._renderTargets.push(n._diffuseTexture),n._reflectionTexture&&n._reflectionTexture.isRenderTarget&&n._renderTargets.push(n._reflectionTexture),n._renderTargets},n}return __extends(r,i),Object.defineProperty(r.prototype,"reflectionStandardFresnelWeight",{set:function(e){var t=e;t<.5?(t*=2,this.reflectionReflectance0=r.standardReflectance0*t,this.reflectionReflectance90=r.standardReflectance90*t):(t=2*t-1,this.reflectionReflectance0=r.standardReflectance0+(1-r.standardReflectance0)*t,this.reflectionReflectance90=r.standardReflectance90+(1-r.standardReflectance90)*t)},enumerable:!0,configurable:!0}),r.prototype._attachImageProcessingConfiguration=function(e){var t=this;e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration=e||this.getScene().imageProcessingConfiguration,this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(e){t._markAllSubMeshesAsImageProcessingDirty()})))},Object.defineProperty(r.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this.imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraColorCurves",{get:function(){return this.imageProcessingConfiguration.colorCurves},set:function(e){this.imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),r.prototype.needAlphaTesting=function(){return!0},r.prototype.needAlphaBlending=function(){return this.alpha<0||null!=this._diffuseTexture&&this._diffuseTexture.hasAlpha},r.prototype.isReadyForSubMesh=function(i,r,n){var o=this;if(void 0===n&&(n=!1),r.effect&&this.isFrozen&&this._wasPreviouslyReady)return!0;r._materialDefines||(r._materialDefines=new t);var s=this.getScene(),a=r._materialDefines;if(!this.checkReadyOnEveryCall&&r.effect&&a._renderId===s.getRenderId())return!0;var l=s.getEngine();if(e.MaterialHelper.PrepareDefinesForLights(s,i,a,!1,this._maxSimultaneousLights),a._needNormals=!0,a._areTexturesDirty){if(a._needUVs=!1,s.texturesEnabled){if(s.getEngine().getCaps().textureLOD&&(a.TEXTURELODSUPPORT=!0),this._diffuseTexture&&e.StandardMaterial.DiffuseTextureEnabled){if(!this._diffuseTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._diffuseTexture,a,"DIFFUSE"),a.DIFFUSEHASALPHA=this._diffuseTexture.hasAlpha,a.GAMMADIFFUSE=this._diffuseTexture.gammaSpace,a.OPACITYFRESNEL=this._opacityFresnel}else a.DIFFUSE=!1,a.DIFFUSEHASALPHA=!1,a.GAMMADIFFUSE=!1,a.OPACITYFRESNEL=!1;var h=this._reflectionTexture;if(h&&e.StandardMaterial.ReflectionTextureEnabled){if(!h.isReadyOrNotBlocking())return!1;switch(a.REFLECTION=!0,a.GAMMAREFLECTION=h.gammaSpace,a.REFLECTIONBLUR=this._reflectionBlur>0,a.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!h.invertZ:h.invertZ,a.LODINREFLECTIONALPHA=h.lodLevelInAlpha,h.coordinatesMode===e.Texture.INVCUBIC_MODE&&(a.INVERTCUBICMAP=!0),a.REFLECTIONMAP_3D=h.isCube,h.coordinatesMode){case e.Texture.CUBIC_MODE:case e.Texture.INVCUBIC_MODE:a.REFLECTIONMAP_CUBIC=!0;break;case e.Texture.EXPLICIT_MODE:a.REFLECTIONMAP_EXPLICIT=!0;break;case e.Texture.PLANAR_MODE:a.REFLECTIONMAP_PLANAR=!0;break;case e.Texture.PROJECTION_MODE:a.REFLECTIONMAP_PROJECTION=!0;break;case e.Texture.SKYBOX_MODE:a.REFLECTIONMAP_SKYBOX=!0;break;case e.Texture.SPHERICAL_MODE:a.REFLECTIONMAP_SPHERICAL=!0;break;case e.Texture.EQUIRECTANGULAR_MODE:a.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case e.Texture.FIXED_EQUIRECTANGULAR_MODE:a.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case e.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:a.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0}this.reflectionFresnel?(a.REFLECTIONFRESNEL=!0,a.REFLECTIONFALLOFF=this.reflectionFalloffDistance>0,this._reflectionControls.x=this.reflectionAmount,this._reflectionControls.y=this.reflectionReflectance0,this._reflectionControls.z=this.reflectionReflectance90,this._reflectionControls.w=1/this.reflectionFalloffDistance):(a.REFLECTIONFRESNEL=!1,a.REFLECTIONFALLOFF=!1)}else a.REFLECTION=!1,a.REFLECTIONFALLOFF=!1,a.REFLECTIONBLUR=!1,a.REFLECTIONMAP_3D=!1,a.REFLECTIONMAP_SPHERICAL=!1,a.REFLECTIONMAP_PLANAR=!1,a.REFLECTIONMAP_CUBIC=!1,a.REFLECTIONMAP_PROJECTION=!1,a.REFLECTIONMAP_SKYBOX=!1,a.REFLECTIONMAP_EXPLICIT=!1,a.REFLECTIONMAP_EQUIRECTANGULAR=!1,a.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,a.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,a.INVERTCUBICMAP=!1,a.REFLECTIONMAP_OPPOSITEZ=!1,a.LODINREFLECTIONALPHA=!1,a.GAMMAREFLECTION=!1}a.PREMULTIPLYALPHA=this.alphaMode===e.Engine.ALPHA_PREMULTIPLIED||this.alphaMode===e.Engine.ALPHA_PREMULTIPLIED_PORTERDUFF,a.USERGBCOLOR=this._useRGBColor,a.NOISE=this._enableNoise}if(a._areImageProcessingDirty){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(a)}if(e.MaterialHelper.PrepareDefinesForMisc(i,s,!1,this.pointsCloud,this.fogEnabled,a),e.MaterialHelper.PrepareDefinesForFrameBoundValues(s,l,a,n,!1),e.MaterialHelper.PrepareDefinesForAttributes(i,a,!1,!0,!1)&&i&&(s.getEngine().getCaps().standardDerivatives||i.isVerticesDataPresent(e.VertexBuffer.NormalKind)||(i.createNormals(!0),e.Tools.Warn("BackgroundMaterial: Normals have been created for the mesh: "+i.name))),a.isDirty){a.markAsProcessed(),s.resetCachedMaterial();var u=new e.EffectFallbacks;a.FOG&&u.addFallback(0,"FOG"),a.POINTSIZE&&u.addFallback(1,"POINTSIZE"),e.MaterialHelper.HandleFallbacksForShadows(a,u,this._maxSimultaneousLights),a.NUM_BONE_INFLUENCERS>0&&u.addCPUSkinningFallback(0,i);var c=[e.VertexBuffer.PositionKind];a.NORMAL&&c.push(e.VertexBuffer.NormalKind),a.UV1&&c.push(e.VertexBuffer.UVKind),a.UV2&&c.push(e.VertexBuffer.UV2Kind),e.MaterialHelper.PrepareAttributesForBones(c,i,a,u),e.MaterialHelper.PrepareAttributesForInstances(c,a);var f=["world","view","viewProjection","vEyePosition","vLightsType","vFogInfos","vFogColor","pointSize","vClipPlane","mBones","vPrimaryColor","vSecondaryColor","vTertiaryColor","vReflectionInfos","reflectionMatrix","vReflectionMicrosurfaceInfos","shadowLevel","alpha","vBackgroundCenter","vReflectionControl","vDiffuseInfos","diffuseMatrix"],d=["diffuseSampler","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh"],p=["Material","Scene"];e.ImageProcessingConfiguration.PrepareUniforms(f,a),e.ImageProcessingConfiguration.PrepareSamplers(d,a),e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:a,maxSimultaneousLights:this._maxSimultaneousLights});var _=function(e){o.onCompiled&&o.onCompiled(e),o.bindSceneUniformBuffer(e,s.getSceneUniformBuffer())},m=a.toString();r.setEffect(s.getEngine().createEffect("background",{attributes:c,uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:m,fallbacks:u,onCompiled:_,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights}},l),a),this.buildUniformLayout()}return!(!r.effect||!r.effect.isReady())&&(a._renderId=s.getRenderId(),this._wasPreviouslyReady=!0,!0)},r.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("vPrimaryColor",4),this._uniformBuffer.addUniform("vSecondaryColor",4),this._uniformBuffer.addUniform("vTertiaryColor",4),this._uniformBuffer.addUniform("vDiffuseInfos",2),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("diffuseMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.addUniform("shadowLevel",1),this._uniformBuffer.addUniform("alpha",1),this._uniformBuffer.addUniform("vBackgroundCenter",3),this._uniformBuffer.addUniform("vReflectionControl",4),this._uniformBuffer.create()},r.prototype.unbind=function(){this._diffuseTexture&&this._diffuseTexture.isRenderTarget&&this._uniformBuffer.setTexture("diffuseSampler",null),this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._uniformBuffer.setTexture("reflectionSampler",null),i.prototype.unbind.call(this)},r.prototype.bindOnlyWorldMatrix=function(e){this._activeEffect.setMatrix("world",e)},r.prototype.bindForSubMesh=function(t,i,r){var n=this.getScene(),o=r._materialDefines;if(o){var s=r.effect;if(s){this._activeEffect=s,this.bindOnlyWorldMatrix(t),e.MaterialHelper.BindBonesParameters(i,this._activeEffect);var a=this._mustRebind(n,s,i.visibility);if(a){this._uniformBuffer.bindToEffect(s,"Material"),this.bindViewProjection(s);var l=this._reflectionTexture;this._uniformBuffer.useUbo&&this.isFrozen&&this._uniformBuffer.isSync||(n.texturesEnabled&&(this._diffuseTexture&&e.StandardMaterial.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),e.MaterialHelper.BindTextureMatrix(this._diffuseTexture,this._uniformBuffer,"diffuse")),l&&e.StandardMaterial.ReflectionTextureEnabled&&(this._uniformBuffer.updateMatrix("reflectionMatrix",l.getReflectionTextureMatrix()),this._uniformBuffer.updateFloat2("vReflectionInfos",l.level,this._reflectionBlur),this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos",l.getSize().width,l.lodGenerationScale,l.lodGenerationOffset))),this.shadowLevel>0&&this._uniformBuffer.updateFloat("shadowLevel",this.shadowLevel),this._uniformBuffer.updateFloat("alpha",this.alpha),this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),this._uniformBuffer.updateColor4("vPrimaryColor",this._primaryColor,this._primaryLevel),this._uniformBuffer.updateColor4("vSecondaryColor",this._secondaryColor,this._secondaryLevel),this._uniformBuffer.updateColor4("vTertiaryColor",this._tertiaryColor,this._tertiaryLevel)),n.texturesEnabled&&(this._diffuseTexture&&e.StandardMaterial.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("diffuseSampler",this._diffuseTexture),l&&e.StandardMaterial.ReflectionTextureEnabled&&(o.REFLECTIONBLUR&&o.TEXTURELODSUPPORT?this._uniformBuffer.setTexture("reflectionSampler",l):o.REFLECTIONBLUR?(this._uniformBuffer.setTexture("reflectionSampler",l._lodTextureMid||l),this._uniformBuffer.setTexture("reflectionSamplerLow",l._lodTextureLow||l),this._uniformBuffer.setTexture("reflectionSamplerHigh",l._lodTextureHigh||l)):this._uniformBuffer.setTexture("reflectionSampler",l),o.REFLECTIONFRESNEL&&(this._uniformBuffer.updateFloat3("vBackgroundCenter",this.sceneCenter.x,this.sceneCenter.y,this.sceneCenter.z),this._uniformBuffer.updateFloat4("vReflectionControl",this._reflectionControls.x,this._reflectionControls.y,this._reflectionControls.z,this._reflectionControls.w)))),e.MaterialHelper.BindClipPlane(this._activeEffect,n),e.MaterialHelper.BindEyePosition(s,n)}!a&&this.isFrozen||(n.lightsEnabled&&e.MaterialHelper.BindLights(n,i,this._activeEffect,o,this._maxSimultaneousLights,!1),this.bindView(s),e.MaterialHelper.BindFogParameters(n,i,this._activeEffect),this._imageProcessingConfiguration.bind(this._activeEffect)),this._uniformBuffer.update(),this._afterBind(i)}}},r.prototype.dispose=function(e,t){void 0===e&&(e=!1),void 0===t&&(t=!1),t&&(this.diffuseTexture&&this.diffuseTexture.dispose(),this.reflectionTexture&&this.reflectionTexture.dispose()),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),i.prototype.dispose.call(this,e)},r.prototype.clone=function(t){var i=this;return e.SerializationHelper.Clone((function(){return new r(t,i.getScene())}),this)},r.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.BackgroundMaterial",t},r.prototype.getClassName=function(){return"BackgroundMaterial"},r.Parse=function(t,i,n){return e.SerializationHelper.Parse((function(){return new r(t.name,i)}),t,i,n)},r.standardReflectance0=.05,r.standardReflectance90=.5,__decorate([e.serializeAsColor3()],r.prototype,"_primaryColor",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],r.prototype,"primaryColor",void 0),__decorate([e.serialize()],r.prototype,"_primaryLevel",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],r.prototype,"primaryLevel",void 0),__decorate([e.serializeAsColor3()],r.prototype,"_secondaryColor",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],r.prototype,"secondaryColor",void 0),__decorate([e.serialize()],r.prototype,"_secondaryLevel",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],r.prototype,"secondaryLevel",void 0),__decorate([e.serializeAsColor3()],r.prototype,"_tertiaryColor",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],r.prototype,"tertiaryColor",void 0),__decorate([e.serialize()],r.prototype,"_tertiaryLevel",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],r.prototype,"tertiaryLevel",void 0),__decorate([e.serializeAsTexture()],r.prototype,"_reflectionTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"reflectionTexture",void 0),__decorate([e.serialize()],r.prototype,"_reflectionBlur",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"reflectionBlur",void 0),__decorate([e.serializeAsTexture()],r.prototype,"_diffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"diffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"shadowLights",void 0),__decorate([e.serialize()],r.prototype,"_shadowBlurScale",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"shadowBlurScale",void 0),__decorate([e.serialize()],r.prototype,"_shadowLevel",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"shadowLevel",void 0),__decorate([e.serializeAsVector3()],r.prototype,"_sceneCenter",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"sceneCenter",void 0),__decorate([e.serialize()],r.prototype,"_opacityFresnel",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"opacityFresnel",void 0),__decorate([e.serialize()],r.prototype,"_reflectionFresnel",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"reflectionFresnel",void 0),__decorate([e.serialize()],r.prototype,"_reflectionFalloffDistance",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"reflectionFalloffDistance",void 0),__decorate([e.serialize()],r.prototype,"_reflectionAmount",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"reflectionAmount",void 0),__decorate([e.serialize()],r.prototype,"_reflectionReflectance0",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"reflectionReflectance0",void 0),__decorate([e.serialize()],r.prototype,"_reflectionReflectance90",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"reflectionReflectance90",void 0),__decorate([e.serialize()],r.prototype,"_useRGBColor",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useRGBColor",void 0),__decorate([e.serialize()],r.prototype,"_enableNoise",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"enableNoise",void 0),__decorate([e.serialize()],r.prototype,"_maxSimultaneousLights",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"maxSimultaneousLights",void 0),__decorate([e.serializeAsImageProcessingConfiguration()],r.prototype,"_imageProcessingConfiguration",void 0),r})(e.PushMaterial);e.BackgroundMaterial=i})(BABYLON||(BABYLON={}));var __assign=this&&this.__assign||Object.assign||function(e){for(var t,i=1,r=arguments.length;it&&(t=2*a),t*=1.1,i*=1.5,r=n.min.add(o.scale(.5)),r.y=n.min.y-s}return{groundSize:t,skyboxSize:i,rootPosition:r}},t.prototype._setupGround=function(t){this._ground||(this._ground=e.Mesh.CreatePlane("BackgroundPlane",t.groundSize,this._scene),this._ground.rotation.x=Math.PI/2,this._ground.parent=this._rootMesh),this._ground.receiveShadows=this._options.enableGroundShadow},t.prototype._setupGroundMaterial=function(){this._groundMaterial||(this._groundMaterial=new e.BackgroundMaterial("BackgroundPlaneMaterial",this._scene)),this._groundMaterial.alpha=this._options.groundOpacity,this._groundMaterial.alphaMode=e.Engine.ALPHA_PREMULTIPLIED_PORTERDUFF,this._groundMaterial.shadowLevel=this._options.groundShadowLevel,this._groundMaterial.primaryLevel=1,this._groundMaterial.primaryColor=this._options.groundColor,this._groundMaterial.secondaryLevel=0,this._groundMaterial.tertiaryLevel=0,this._groundMaterial.useRGBColor=!1,this._groundMaterial.enableNoise=!0,this._ground&&(this._ground.material=this._groundMaterial)},t.prototype._setupGroundDiffuseTexture=function(){if(this._groundMaterial&&!this._groundTexture){if(this._options.groundTexture instanceof e.BaseTexture)return void(this._groundMaterial.diffuseTexture=this._options.groundTexture);var t=new e.Texture(this._options.groundTexture,this._scene);t.gammaSpace=!1,t.hasAlpha=!0,this._groundMaterial.diffuseTexture=t}},t.prototype._setupGroundMirrorTexture=function(t){var i=e.Texture.CLAMP_ADDRESSMODE;if(!this._groundMirror&&(this._groundMirror=new e.MirrorTexture("BackgroundPlaneMirrorTexture",{ratio:this._options.groundMirrorSizeRatio},this._scene,!1,this._options.groundMirrorTextureType,e.Texture.BILINEAR_SAMPLINGMODE,!0),this._groundMirror.mirrorPlane=new e.Plane(0,-1,0,t.rootPosition.y),this._groundMirror.anisotropicFilteringLevel=1,this._groundMirror.wrapU=i,this._groundMirror.wrapV=i,this._groundMirror.gammaSpace=!1,this._groundMirror.renderList))for(var r=0;r\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include\n#include\n\n#include\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nvarying vec2 vDiffuseUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nvarying vec2 vSpecularUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include\n#include\n#include\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include\n#include[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include\nvoid main(void) {\nvec3 positionUpdated=position;\n#ifdef NORMAL \nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=positionUpdated;\n#endif \n#include\n#include\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nif (vSpecularInfos.x == 0.)\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#include\n#include\n#include\n#include[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n#include\n#include\n}",defaultPixelShader:"#include<__decl__defaultFragment>\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n\n#define RECIPROCAL_PI2 0.15915494\nuniform vec3 vEyePosition;\nuniform vec3 vAmbientColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n\n#include\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include\n#include\n\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY \n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\nuniform samplerCube refractionCubeSampler;\n#else\nuniform sampler2D refraction2DSampler;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\n#if SPECULARDIRECTUV == 1\n#define vSpecularUV vMainUV1\n#elif SPECULARDIRECTUV == 2\n#define vSpecularUV vMainUV2\n#else\nvarying vec2 vSpecularUV;\n#endif\nuniform sampler2D specularSampler;\n#endif\n\n#include\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\nuniform samplerCube reflectionCubeSampler;\n#else\nuniform sampler2D reflection2DSampler;\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include\n#endif\n#include\n#include\n#include\n#include\n#include\n#include\nvoid main(void) {\n#include\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));\n#endif\n#include\n#ifdef TWOSIDEDLIGHTING\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#ifdef ALPHAFROMDIFFUSE\nalpha*=baseColor.a;\n#endif\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#include\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\nvec3 baseAmbientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nbaseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#endif\n\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#ifdef SPECULAR\nvec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);\nspecularColor=specularMapColor.rgb;\n#ifdef GLOSSINESS\nglossiness=glossiness*specularMapColor.a;\n#endif\n#endif\n#else\nfloat glossiness=0.;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\nfloat shadow=1.;\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\n#include[0..maxSimultaneousLights]\n\nvec3 refractionColor=vec3(0.,0.,0.);\n#ifdef REFRACTION\nvec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nif (dot(refractionVector,viewDirectionW)<1.0)\n{\nrefractionColor=textureCube(refractionCubeSampler,refractionVector).rgb*vRefractionInfos.x;\n}\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\nrefractionColor=texture2D(refraction2DSampler,refractionCoords).rgb*vRefractionInfos.x;\n#endif\n#endif\n\nvec3 reflectionColor=vec3(0.,0.,0.);\n#ifdef REFLECTION\nvec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_3D\n#ifdef ROUGHNESS\nfloat bias=vReflectionInfos.y;\n#ifdef SPECULARTERM\n#ifdef SPECULAR\n#ifdef GLOSSINESS\nbias*=(1.0-specularMapColor.a);\n#endif\n#endif\n#endif\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias).rgb*vReflectionInfos.x;\n#else\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW).rgb*vReflectionInfos.x;\n#endif\n#else\nvec2 coords=vReflectionUVW.xy;\n#ifdef REFLECTIONMAP_PROJECTION\ncoords/=vReflectionUVW.z;\n#endif\ncoords.y=1.0-coords.y;\nreflectionColor=texture2D(reflection2DSampler,coords).rgb*vReflectionInfos.x;\n#endif\n#ifdef REFLECTIONFRESNEL\nfloat reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);\n#ifdef REFLECTIONFRESNELFROMSPECULAR\n#ifdef SPECULARTERM\nreflectionColor*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#endif\n#endif\n#ifdef REFRACTIONFRESNEL\nfloat refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);\nrefractionColor*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nopacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);\nalpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;\n#else\nalpha*=opacityMap.a*vOpacityInfos.y;\n#endif\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef OPACITYFRESNEL\nfloat opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);\nalpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;\n#endif\n\nvec3 emissiveColor=vEmissiveColor;\n#ifdef EMISSIVE\nemissiveColor+=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y;\n#endif\n#ifdef EMISSIVEFRESNEL\nfloat emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);\nemissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;\n#endif\n\n#ifdef DIFFUSEFRESNEL\nfloat diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);\ndiffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\n#ifdef LINKEMISSIVEWITHDIFFUSE\nvec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#endif\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#ifdef SPECULAROVERALPHA\nalpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#ifdef REFLECTIONOVERALPHA\nalpha=clamp(alpha+dot(reflectionColor,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+emissiveColor+refractionColor,0.0,1.0),alpha);\n#else\nvec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+refractionColor,alpha);\n#endif\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor;\n#else\ncolor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n#include\n#include\n\n\n#ifdef IMAGEPROCESSINGPOSTPROCESS\ncolor.rgb=toLinearSpace(color.rgb);\n#else\n#ifdef IMAGEPROCESSING\ncolor.rgb=toLinearSpace(color.rgb);\ncolor=applyImageProcessing(color);\n#endif\n#endif\n#ifdef PREMULTIPLYALPHA\n\ncolor.rgb*=color.a;\n#endif\ngl_FragColor=color;\n}",pbrVertexShader:"precision highp float;\n#include<__decl__pbrVertex>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2; \n#endif \n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include\n#include\n\n#include\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nvarying vec2 vAlbedoUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nvarying vec2 vReflectivityUV;\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#include\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include\n#include\n#include\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include\n#include[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include\nvoid main(void) {\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=positionUpdated;\n#endif \n#include\n#include\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\nvEnvironmentIrradiance=environmentIrradianceJones(reflectionVector);\n#endif\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif \n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif \n#if defined(ALBEDO) && ALBEDODIRECTUV == 0 \nif (vAlbedoInfos.x == 0.)\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0 \nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0 \nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0 \nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0 \nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0 \nif (vReflectivityInfos.x == 0.)\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0 \nif (vMicroSurfaceSamplerInfos.x == 0.)\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0 \nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include\n\n#include\n\n#include\n\n#include[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n\n#include\n}", pbrPixelShader:"#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LODBASEDMICROSFURACE\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nprecision highp float;\n#include<__decl__pbrFragment>\nuniform vec4 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec4 vCameraInfos;\n\nvarying vec3 vPositionW;\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif \n#ifdef MAINUV2 \nvarying vec2 vMainUV2;\n#endif \n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef ALBEDO\n#if ALBEDODIRECTUV == 1\n#define vAlbedoUV vMainUV1\n#elif ALBEDODIRECTUV == 2\n#define vAlbedoUV vMainUV2\n#else\nvarying vec2 vAlbedoUV;\n#endif\nuniform sampler2D albedoSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFLECTIVITY\n#if REFLECTIVITYDIRECTUV == 1\n#define vReflectivityUV vMainUV1\n#elif REFLECTIVITYDIRECTUV == 2\n#define vReflectivityUV vMainUV2\n#else\nvarying vec2 vReflectivityUV;\n#endif\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef MICROSURFACEMAP\n#if MICROSURFACEMAPDIRECTUV == 1\n#define vMicroSurfaceSamplerUV vMainUV1\n#elif MICROSURFACEMAPDIRECTUV == 2\n#define vMicroSurfaceSamplerUV vMainUV2\n#else\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\nuniform sampler2D microSurfaceSampler;\n#endif\n\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\n#define sampleRefraction(s,c) textureCube(s,c)\nuniform samplerCube refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#else\n#define sampleRefraction(s,c) texture2D(s,c)\nuniform sampler2D refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#endif\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include\n#endif\n#ifdef ENVIRONMENTBRDF\nuniform sampler2D environmentBrdfSampler;\n#endif\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n#include\n#include\n#include\n\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\n#include\nvoid main(void) {\n#include\n\n\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#endif\n#include\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nvec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#if defined(TWOSIDEDLIGHTING)\nfaceNormal=gl_FrontFacing ? faceNormal : -faceNormal;\n#endif\nnormalW*=sign(dot(normalW,faceNormal));\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n\n\nvec3 surfaceAlbedo=vAlbedoColor.rgb;\n\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\nvec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);\n#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)\nalpha*=albedoTexture.a;\n#endif\nsurfaceAlbedo*=toLinearSpace(albedoTexture.rgb);\nsurfaceAlbedo*=vAlbedoInfos.y;\n#endif\n\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nalpha=getLuminance(opacityMap.rgb);\n#else\nalpha*=opacityMap.a;\n#endif\nalpha*=vOpacityInfos.y;\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#if !defined(LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)\n#ifdef ALPHATEST\nif (alpha<=ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#include\n#ifdef VERTEXCOLOR\nsurfaceAlbedo*=vColor.rgb;\n#endif\n\nvec3 ambientOcclusionColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nvec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#ifdef AMBIENTINGRAYSCALE\nambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);\n#endif\nambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);\n#endif\n\nfloat microSurface=vReflectivityColor.a;\nvec3 surfaceReflectivityColor=vReflectivityColor.rgb;\n#ifdef METALLICWORKFLOW\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\n#ifdef REFLECTIVITY\nvec4 surfaceMetallicColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\n#ifdef AOSTOREINMETALMAPRED\nvec3 aoStoreInMetalMap=vec3(surfaceMetallicColorMap.r,surfaceMetallicColorMap.r,surfaceMetallicColorMap.r);\nambientOcclusionColor=mix(ambientOcclusionColor,aoStoreInMetalMap,vReflectivityInfos.z);\n#endif\n#ifdef METALLNESSSTOREINMETALMAPBLUE\nmetallicRoughness.r*=surfaceMetallicColorMap.b;\n#else\nmetallicRoughness.r*=surfaceMetallicColorMap.r;\n#endif\n#ifdef ROUGHNESSSTOREINMETALMAPALPHA\nmetallicRoughness.g*=surfaceMetallicColorMap.a;\n#else\n#ifdef ROUGHNESSSTOREINMETALMAPGREEN\nmetallicRoughness.g*=surfaceMetallicColorMap.g;\n#endif\n#endif\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmetallicRoughness.g*=microSurfaceTexel.r;\n#endif\n\nmicroSurface=1.0-metallicRoughness.g;\n\nvec3 baseColor=surfaceAlbedo;\n\n\nconst vec3 DefaultSpecularReflectanceDielectric=vec3(0.04,0.04,0.04);\n\nsurfaceAlbedo=mix(baseColor.rgb*(1.0-DefaultSpecularReflectanceDielectric.r),vec3(0.,0.,0.),metallicRoughness.r);\n\nsurfaceReflectivityColor=mix(DefaultSpecularReflectanceDielectric,baseColor,metallicRoughness.r);\n#else\n#ifdef REFLECTIVITY\nvec4 surfaceReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\nsurfaceReflectivityColor*=toLinearSpace(surfaceReflectivityColorMap.rgb);\nsurfaceReflectivityColor*=vReflectivityInfos.y;\n#ifdef MICROSURFACEFROMREFLECTIVITYMAP\nmicroSurface*=surfaceReflectivityColorMap.a;\nmicroSurface*=vReflectivityInfos.z;\n#else\n#ifdef MICROSURFACEAUTOMATIC\nmicroSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmicroSurface*=microSurfaceTexel.r;\n#endif\n#endif\n#endif\n#endif\n\nmicroSurface=clamp(microSurface,0.,1.);\n\nfloat roughness=1.-microSurface;\n\n#ifdef ALPHAFRESNEL\n#if defined(ALPHATEST) || defined(ALPHABLEND)\n\n\n\nfloat opacityPerceptual=alpha;\nfloat opacity0=opacityPerceptual*opacityPerceptual;\nfloat opacity90=fresnelGrazingReflectance(opacity0);\nvec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);\n\nalpha=fresnelSchlickEnvironmentGGX(clamp(dot(viewDirectionW,normalForward),0.0,1.0),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;\n#ifdef ALPHATEST\nif (alpha<=ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#endif\n\n\nfloat NdotVUnclamped=dot(normalW,viewDirectionW);\nfloat NdotV=clamp(NdotVUnclamped,0.,1.)+0.00001;\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\n\n#ifdef REFRACTION\nvec3 environmentRefraction=vec3(0.,0.,0.);\nvec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);\n#ifdef REFRACTIONMAP_OPPOSITEZ\nrefractionVector.z*=-1.0;\n#endif\n\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nvec3 refractionCoords=refractionVector;\nrefractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\n#endif\n#ifdef LODINREFRACTIONALPHA\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,1.0);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nrefractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;\n#ifdef LODINREFRACTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);\nfloat requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);\n#else\nfloat requestedRefractionLOD=refractionLOD;\n#endif\nenvironmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD).rgb;\n#else\nfloat lodRefractionNormalized=clamp(refractionLOD/log2(vRefractionMicrosurfaceInfos.x),0.,1.);\nfloat lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;\nvec3 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords).rgb;\nif(lodRefractionNormalizedDoubled<1.0){\nenvironmentRefraction=mix(\nsampleRefraction(refractionSamplerHigh,refractionCoords).rgb,\nenvironmentRefractionMid,\nlodRefractionNormalizedDoubled\n);\n}else{\nenvironmentRefraction=mix(\nenvironmentRefractionMid,\nsampleRefraction(refractionSamplerLow,refractionCoords).rgb,\nlodRefractionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef GAMMAREFRACTION\nenvironmentRefraction=toLinearSpace(environmentRefraction.rgb);\n#endif\n\nenvironmentRefraction*=vRefractionInfos.x;\n#endif\n\n#ifdef REFLECTION\nvec3 environmentRadiance=vec3(0.,0.,0.);\nvec3 environmentIrradiance=vec3(0.,0.,0.);\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,1.);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nreflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\n#ifdef LODINREFLECTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);\nfloat requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);\n#else\nfloat requestedReflectionLOD=reflectionLOD;\n#endif\nenvironmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,requestedReflectionLOD).rgb;\n#else\nfloat lodReflectionNormalized=clamp(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x),0.,1.);\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec3 environmentSpecularMid=sampleReflection(reflectionSampler,reflectionCoords).rgb;\nif(lodReflectionNormalizedDoubled<1.0){\nenvironmentRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords).rgb,\nenvironmentSpecularMid,\nlodReflectionNormalizedDoubled\n);\n}else{\nenvironmentRadiance=mix(\nenvironmentSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords).rgb,\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentRadiance=toLinearSpace(environmentRadiance.rgb);\n#endif\n\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\nenvironmentIrradiance=vEnvironmentIrradiance;\n#else\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;\n#endif\nenvironmentIrradiance=environmentIrradianceJones(irradianceVector);\n#endif\n#endif\n\nenvironmentRadiance*=vReflectionInfos.x;\nenvironmentRadiance*=vReflectionColor.rgb;\nenvironmentIrradiance*=vReflectionColor.rgb;\n#endif\n\n\n\nfloat reflectance=max(max(surfaceReflectivityColor.r,surfaceReflectivityColor.g),surfaceReflectivityColor.b);\nfloat reflectance90=fresnelGrazingReflectance(reflectance);\nvec3 specularEnvironmentR0=surfaceReflectivityColor.rgb;\nvec3 specularEnvironmentR90=vec3(1.0,1.0,1.0)*reflectance90;\n\nvec3 diffuseBase=vec3(0.,0.,0.);\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\nlightingInfo info;\nfloat shadow=1.; \nfloat NdotL=-1.;\n#include[0..maxSimultaneousLights]\n\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n\nvec2 brdfSamplerUV=vec2(NdotV,roughness);\n\nvec4 environmentBrdf=texture2D(environmentBrdfSampler,brdfSamplerUV);\nvec3 specularEnvironmentReflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;\n#ifdef AMBIENTINGRAYSCALE\nfloat ambientMonochrome=ambientOcclusionColor.r;\n#else\nfloat ambientMonochrome=getLuminance(ambientOcclusionColor);\n#endif\nfloat seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);\nspecularEnvironmentReflectance*=seo;\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat eho=environmentHorizonOcclusion(reflectionCoords,normalW);\nspecularEnvironmentReflectance*=eho;\n#endif\n#endif\n#else\n\nvec3 specularEnvironmentReflectance=fresnelSchlickEnvironmentGGX(NdotV,specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));\n#endif\n\n#ifdef REFRACTION\nvec3 refractance=vec3(0.0,0.0,0.0);\nvec3 transmission=vec3(1.0,1.0,1.0);\n#ifdef LINKREFRACTIONTOTRANSPARENCY\n\ntransmission*=(1.0-alpha);\n\n\nvec3 mixedAlbedo=surfaceAlbedo;\nfloat maxChannel=max(max(mixedAlbedo.r,mixedAlbedo.g),mixedAlbedo.b);\nvec3 tint=clamp(maxChannel*mixedAlbedo,0.0,1.0);\n\nsurfaceAlbedo*=alpha;\n\nenvironmentIrradiance*=alpha;\n\nenvironmentRefraction*=tint;\n\nalpha=1.0;\n#endif\n\nvec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);\nspecularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,alpha);\n\ntransmission*=1.0-specularEnvironmentReflectance;\n\nrefractance=transmission;\n#endif\n\n\n\n\nsurfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;\n\nvec3 finalDiffuse=diffuseBase;\nfinalDiffuse.rgb+=vAmbientColor;\nfinalDiffuse*=surfaceAlbedo.rgb;\nfinalDiffuse=max(finalDiffuse,0.0);\n\n#ifdef REFLECTION\nvec3 finalIrradiance=environmentIrradiance;\nfinalIrradiance*=surfaceAlbedo.rgb;\n#endif\n\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase;\nfinalSpecular=max(finalSpecular,0.0);\n\nvec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;\n#endif\n\n#ifdef REFLECTION\nvec3 finalRadiance=environmentRadiance;\nfinalRadiance*=specularEnvironmentReflectance;\n\nvec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;\n#endif\n\n#ifdef REFRACTION\nvec3 finalRefraction=environmentRefraction;\nfinalRefraction*=refractance;\n#endif\n\nvec3 finalEmissive=vEmissiveColor;\n#ifdef EMISSIVE\nvec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;\nfinalEmissive*=toLinearSpace(emissiveColorTex.rgb);\nfinalEmissive*=vEmissiveInfos.y;\n#endif\n\n#ifdef ALPHABLEND\nfloat luminanceOverAlpha=0.0;\n#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalRadianceScaled);\n#endif\n#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)\nluminanceOverAlpha+=getLuminance(finalSpecularScaled);\n#endif\n#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA)\nalpha=clamp(alpha+luminanceOverAlpha*luminanceOverAlpha,0.,1.);\n#endif\n#endif\n\n\n\nvec4 finalColor=vec4(finalDiffuse*ambientOcclusionColor*vLightingIntensity.x +\n#ifdef REFLECTION\nfinalIrradiance*ambientOcclusionColor*vLightingIntensity.z +\n#endif\n#ifdef SPECULARTERM\n\n\nfinalSpecularScaled +\n#endif\n#ifdef REFLECTION\n\n\nfinalRadianceScaled +\n#endif\n#ifdef REFRACTION\nfinalRefraction*vLightingIntensity.z +\n#endif\nfinalEmissive*vLightingIntensity.y,\nalpha);\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\nfinalColor.rgb*=lightmapColor;\n#else\nfinalColor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n\nfinalColor=max(finalColor,0.0);\n#include\n#include(color,finalColor)\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\nfinalColor.rgb=clamp(finalColor.rgb,0.,30.0);\n#else\n\nfinalColor=applyImageProcessing(finalColor);\n#endif\n#ifdef PREMULTIPLYALPHA\n\nfinalColor.rgb*=finalColor.a;\n#endif\ngl_FragColor=finalColor;\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n}",spritesVertexShader:"\nattribute vec4 position;\nattribute vec4 options;\nattribute vec4 cellInfo;\nattribute vec4 color;\n\nuniform vec2 textureInfos;\nuniform mat4 view;\nuniform mat4 projection;\n\nvarying vec2 vUV;\nvarying vec4 vColor;\n#include\nvoid main(void) { \nvec3 viewPos=(view*vec4(position.xyz,1.0)).xyz; \nvec2 cornerPos;\nfloat angle=position.w;\nvec2 size=vec2(options.x,options.y);\nvec2 offset=options.zw;\nvec2 uvScale=textureInfos.xy;\ncornerPos=vec2(offset.x-0.5,offset.y-0.5)*size;\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\n\nviewPos+=rotatedCorner;\ngl_Position=projection*vec4(viewPos,1.0); \n\nvColor=color;\n\nvec2 uvOffset=vec2(abs(offset.x-cellInfo.x),1.0-abs(offset.y-cellInfo.y));\nvUV=(uvOffset+cellInfo.zw)*uvScale;\n\n#ifdef FOG\nvFogDistance=viewPos;\n#endif\n}",spritesPixelShader:"uniform bool alphaTest;\nvarying vec4 vColor;\n\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n\n#include\nvoid main(void) {\nvec4 color=texture2D(diffuseSampler,vUV);\nif (alphaTest) \n{\nif (color.a<0.95)\ndiscard;\n}\ncolor*=vColor;\n#include\ngl_FragColor=color;\n}",particlesVertexShader:"\nattribute vec3 position;\nattribute vec4 color;\nattribute vec4 options;\nattribute float cellIndex;\n\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec3 particlesInfos; \n\nvarying vec2 vUV;\nvarying vec4 vColor;\n#ifdef CLIPPLANE\nuniform vec4 vClipPlane;\nuniform mat4 invView;\nvarying float fClipDistance;\n#endif\nvoid main(void) { \nvec3 viewPos=(view*vec4(position,1.0)).xyz; \nvec3 cornerPos;\nfloat size=options.y;\nfloat angle=options.x;\nvec2 offset=options.zw;\ncornerPos=vec3(offset.x-0.5,offset.y-0.5,0.)*size;\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\n\nviewPos+=rotatedCorner;\ngl_Position=projection*vec4(viewPos,1.0); \nvColor=color;\n#ifdef ANIMATESHEET\nfloat rowOffset=floor(cellIndex/particlesInfos.z);\nfloat columnOffset=cellIndex-rowOffset*particlesInfos.z;\nvec2 uvScale=particlesInfos.xy;\nvec2 uvOffset=vec2(offset.x ,1.0-offset.y);\nvUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;\n#else\nvUV=offset;\n#endif\n\n#ifdef CLIPPLANE\nvec4 worldPos=invView*vec4(viewPos,1.0);\nfClipDistance=dot(worldPos,vClipPlane);\n#endif\n}",particlesPixelShader:"\nvarying vec2 vUV;\nvarying vec4 vColor;\nuniform vec4 textureMask;\nuniform sampler2D diffuseSampler;\n#ifdef CLIPPLANE\nvarying float fClipDistance;\n#endif\nvoid main(void) {\n#ifdef CLIPPLANE\nif (fClipDistance>0.0)\ndiscard;\n#endif\nvec4 baseColor=texture2D(diffuseSampler,vUV);\ngl_FragColor=(baseColor*textureMask+(vec4(1.,1.,1.,1.)-textureMask))*vColor;\n}",gpuRenderParticlesVertexShader:"#version 300 es\n\nin vec3 position;\nin float age;\nin float life;\nin vec3 velocity;\nvoid main() {\ngl_PointSize=1.0;\ngl_Position=vec4(position,1.0);\n}",gpuRenderParticlesPixelShader:"void main() {\ngl_FragColor=vec4(1.0);\n}\n",gpuUpdateParticlesVertexShader:"#version 300 es\nuniform float timeDelta;\n\nin vec3 position;\nin float age;\nin float life;\nin vec3 velocity;\n\nout vec3 outPosition;\nout float outAge;\nout float outLife;\nout vec3 outVelocity;\nvoid main() {\nif (age>=life) {\n\noutPosition=vec3(0,0,0);\n\noutAge=0.0;\noutLife=life;\n\noutVelocity=vec3(0,1,0);\n} else {\noutPosition=position+velocity*timeDelta;\noutAge=age+timeDelta;\noutLife=life;\noutVelocity=velocity;\n}\n}",gpuUpdateParticlesPixelShader:"#version 300 es\nvoid main() {\ndiscard;\n}\n",colorVertexShader:"\nattribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include\n\nuniform mat4 viewProjection;\nuniform mat4 world;\n\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\nvoid main(void) {\nmat4 finalWorld=world;\n#include\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n}",colorPixelShader:"#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#else\nuniform vec4 color;\n#endif\nvoid main(void) {\n#ifdef VERTEXCOLOR\ngl_FragColor=vColor;\n#else\ngl_FragColor=color;\n#endif\n}",postprocessVertexShader:"\nattribute vec2 position;\nuniform vec2 scale;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nvUV=(position*madd+madd)*scale;\ngl_Position=vec4(position,0.0,1.0);\n}",passPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void) \n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}",shadowMapVertexShader:"\nattribute vec3 position;\n#include\n\n#include\nuniform mat4 viewProjection;\nuniform vec2 biasAndScale;\nuniform vec2 depthValues;\nvarying float vDepthMetric;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\nvoid main(void)\n{\n#include\n#include\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y))+biasAndScale.x;\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}",shadowMapPixelShader:"#ifndef FLOAT\nvec4 pack(float depth)\n{\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(depth*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\n#endif\nvarying float vDepthMetric;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\nuniform vec2 biasAndScale;\nuniform vec2 depthValues;\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\nfloat depth=vDepthMetric;\n#ifdef ESM\ndepth=clamp(exp(-min(87.,biasAndScale.y*depth)),0.,1.);\n#endif\n#ifdef FLOAT\ngl_FragColor=vec4(depth,1.0,1.0,1.0);\n#else\ngl_FragColor=pack(depth);\n#endif\n}",depthBoxBlurPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec2 screenSize;\nvoid main(void)\n{\nvec4 colorDepth=vec4(0.0);\nfor (int x=-OFFSET; x<=OFFSET; x++)\nfor (int y=-OFFSET; y<=OFFSET; y++)\ncolorDepth+=texture2D(textureSampler,vUV+vec2(x,y)/screenSize);\ngl_FragColor=(colorDepth/float((OFFSET*2+1)*(OFFSET*2+1)));\n}",proceduralVertexShader:"\nattribute vec2 position;\n\nvarying vec2 vPosition;\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nvPosition=position;\nvUV=position*madd+madd;\ngl_Position=vec4(position,0.0,1.0);\n}",depthVertexShader:"\nattribute vec3 position;\n#include\n\n#include\nuniform mat4 viewProjection;\nuniform vec2 depthValues;\n#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\nvarying float vDepthMetric;\nvoid main(void)\n{\n#include\n#include\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y));\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}",depthPixelShader:"#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\nvarying float vDepthMetric;\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\ngl_FragColor=vec4(vDepthMetric,vDepthMetric*vDepthMetric,0.0,1.0);\n}",ssaoPixelShader:"\nuniform sampler2D textureSampler;\nvarying vec2 vUV;\n#ifdef SSAO\nuniform sampler2D randomSampler;\nuniform float randTextureTiles;\nuniform float samplesFactor;\nuniform vec3 sampleSphere[SAMPLES];\nuniform float totalStrength;\nuniform float radius;\nuniform float area;\nuniform float fallOff;\nuniform float base;\nvec3 normalFromDepth(float depth,vec2 coords)\n{\nvec2 offset1=vec2(0.0,radius);\nvec2 offset2=vec2(radius,0.0);\nfloat depth1=texture2D(textureSampler,coords+offset1).r;\nfloat depth2=texture2D(textureSampler,coords+offset2).r;\nvec3 p1=vec3(offset1,depth1-depth);\nvec3 p2=vec3(offset2,depth2-depth);\nvec3 normal=cross(p1,p2);\nnormal.z=-normal.z;\nreturn normalize(normal);\n}\nvoid main()\n{\nvec3 random=normalize(texture2D(randomSampler,vUV*randTextureTiles).rgb);\nfloat depth=texture2D(textureSampler,vUV).r;\nvec3 position=vec3(vUV,depth);\nvec3 normal=normalFromDepth(depth,vUV);\nfloat radiusDepth=radius/depth;\nfloat occlusion=0.0;\nvec3 ray;\nvec3 hemiRay;\nfloat occlusionDepth;\nfloat difference;\nfor (int i=0; imaxZ) {\ngl_FragColor=vec4(1.0,1.0,1.0,1.0);\nreturn;\n}\nfor (int i=0; i1.0 || offset.y>1.0) {\ncontinue;\n}\n\nfloat sampleDepth=abs(texture2D(textureSampler,offset.xy).r);\n\nfloat rangeCheck=abs(depth-sampleDepth)=1e-5 ? 1.0 : 0.0)*rangeCheck;\n}\n\nfloat ao=1.0-totalStrength*occlusion*samplesFactor;\nfloat result=clamp(ao+base,0.0,1.0);\ngl_FragColor=vec4(vec3(result),1.0);\n}\n#endif\n#ifdef BILATERAL_BLUR\nuniform sampler2D depthSampler;\nuniform float outSize;\nuniform float samplerOffsets[SAMPLES];\nvec4 blur9(sampler2D image,vec2 uv,float resolution,vec2 direction) {\nvec4 color=vec4(0.0);\nvec2 off1=vec2(1.3846153846)*direction;\nvec2 off2=vec2(3.2307692308)*direction;\ncolor+=texture2D(image,uv)*0.2270270270;\ncolor+=texture2D(image,uv+(off1/resolution))*0.3162162162;\ncolor+=texture2D(image,uv-(off1/resolution))*0.3162162162;\ncolor+=texture2D(image,uv+(off2/resolution))*0.0702702703;\ncolor+=texture2D(image,uv-(off2/resolution))*0.0702702703;\nreturn color;\n}\nvec4 blur13(sampler2D image,vec2 uv,float resolution,vec2 direction) {\nvec4 color=vec4(0.0);\nvec2 off1=vec2(1.411764705882353)*direction;\nvec2 off2=vec2(3.2941176470588234)*direction;\nvec2 off3=vec2(5.176470588235294)*direction;\ncolor+=texture2D(image,uv)*0.1964825501511404;\ncolor+=texture2D(image,uv+(off1/resolution))*0.2969069646728344;\ncolor+=texture2D(image,uv-(off1/resolution))*0.2969069646728344;\ncolor+=texture2D(image,uv+(off2/resolution))*0.09447039785044732;\ncolor+=texture2D(image,uv-(off2/resolution))*0.09447039785044732;\ncolor+=texture2D(image,uv+(off3/resolution))*0.010381362401148057;\ncolor+=texture2D(image,uv-(off3/resolution))*0.010381362401148057;\nreturn color;\n}\nvec4 blur13Bilateral(sampler2D image,vec2 uv,float resolution,vec2 direction) {\nvec4 color=vec4(0.0);\nvec2 off1=vec2(1.411764705882353)*direction;\nvec2 off2=vec2(3.2941176470588234)*direction;\nvec2 off3=vec2(5.176470588235294)*direction;\nfloat compareDepth=abs(texture2D(depthSampler,uv).r);\nfloat sampleDepth;\nfloat weight;\nfloat weightSum=30.0;\ncolor+=texture2D(image,uv)*30.0;\nsampleDepth=abs(texture2D(depthSampler,uv+(off1/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv+(off1/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv-(off1/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv-(off1/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv+(off2/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv+(off2/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv-(off2/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv-(off2/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv+(off3/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv+(off3/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv-(off3/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv-(off3/resolution))*weight;\nreturn color/weightSum;\n}\nvoid main()\n{\n#if EXPENSIVE\nfloat compareDepth=abs(texture2D(depthSampler,vUV).r);\nfloat texelsize=1.0/outSize;\nfloat result=0.0;\nfloat weightSum=0.0;\nfor (int i=0; i0.0) {\n\nvec3 ref_indices=vec3(-0.3,0.0,0.3);\nfloat ref_shiftX=chromatic_aberration*radius*17.0/screen_width;\nfloat ref_shiftY=chromatic_aberration*radius*17.0/screen_height;\n\nvec2 ref_coords_r=vec2(vUV.x+ref_indices.r*ref_shiftX,vUV.y+ref_indices.r*ref_shiftY*0.5);\nvec2 ref_coords_g=vec2(vUV.x+ref_indices.g*ref_shiftX,vUV.y+ref_indices.g*ref_shiftY*0.5);\nvec2 ref_coords_b=vec2(vUV.x+ref_indices.b*ref_shiftX,vUV.y+ref_indices.b*ref_shiftY*0.5);\noriginal.r=texture2D(textureSampler,ref_coords_r).r;\noriginal.g=texture2D(textureSampler,ref_coords_g).g;\noriginal.b=texture2D(textureSampler,ref_coords_b).b;\n}\ngl_FragColor=original;\n}",lensHighlightsPixelShader:"\nuniform sampler2D textureSampler; \n\nuniform float gain;\nuniform float threshold;\nuniform float screen_width;\nuniform float screen_height;\n\nvarying vec2 vUV;\n\nvec4 highlightColor(vec4 color) {\nvec4 highlight=color;\nfloat luminance=dot(highlight.rgb,vec3(0.2125,0.7154,0.0721));\nfloat lum_threshold;\nif (threshold>1.0) { lum_threshold=0.94+0.01*threshold; }\nelse { lum_threshold=0.5+0.44*threshold; }\nluminance=clamp((luminance-lum_threshold)*(1.0/(1.0-lum_threshold)),0.0,1.0);\nhighlight*=luminance*gain;\nhighlight.a=1.0;\nreturn highlight;\n}\nvoid main(void)\n{\nvec4 original=texture2D(textureSampler,vUV);\n\nif (gain == -1.0) {\ngl_FragColor=vec4(0.0,0.0,0.0,1.0);\nreturn;\n}\nfloat w=2.0/screen_width;\nfloat h=2.0/screen_height;\nfloat weight=1.0;\n\nvec4 blurred=vec4(0.0,0.0,0.0,0.0);\n#ifdef PENTAGON\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.84*w,0.43*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.48*w,-1.29*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.61*w,1.51*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.55*w,-0.74*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.71*w,-0.52*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.94*w,1.59*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.40*w,-1.87*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.62*w,1.16*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.09*w,0.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.46*w,-1.71*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.08*w,2.42*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.85*w,-1.89*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.89*w,0.16*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.29*w,1.88*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.40*w,-2.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.54*w,2.26*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.60*w,-0.61*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.31*w,-1.30*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.83*w,2.53*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.12*w,-2.48*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.60*w,1.11*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.99*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.50*w,-2.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.85*w,3.33*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.94*w,-1.92*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.27*w,-0.53*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.95*w,2.48*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.23*w,-3.04*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.17*w,2.05*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.97*w,-0.04*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.25*w,-2.00*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.31*w,3.08*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.94*w,-2.59*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.37*w,0.64*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.13*w,1.93*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.03*w,-3.65*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.60*w,3.17*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.14*w,-1.19*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.00*w,-1.19*h)));\n#else\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.85*w,0.36*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.52*w,-1.14*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.46*w,1.42*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.46*w,-0.83*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.79*w,-0.42*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.11*w,1.62*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.29*w,-2.07*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.69*w,1.39*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.28*w,0.12*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.65*w,-1.69*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.08*w,2.44*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.63*w,-1.90*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.55*w,0.31*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.13*w,1.52*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.56*w,-2.61*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.38*w,2.34*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.64*w,-0.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.53*w,-1.21*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.06*w,2.63*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.00*w,-2.69*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.59*w,1.32*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.78*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.57*w,-2.50*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.54*w,2.93*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.39*w,-1.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,-0.28*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.04*w,2.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.02*w,-3.05*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.09*w,2.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.07*w,-0.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.44*w,-1.90*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.52*w,3.05*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.68*w,-2.61*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,0.79*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.76*w,1.46*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.05*w,-2.94*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.21*w,2.88*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.84*w,-1.30*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.98*w,-0.96*h)));\n#endif\nblurred/=39.0;\ngl_FragColor=blurred;\n\n}",depthOfFieldPixelShader:"\n\n\n\n\nuniform sampler2D textureSampler;\nuniform sampler2D highlightsSampler;\nuniform sampler2D depthSampler;\nuniform sampler2D grainSampler;\n\nuniform float grain_amount;\nuniform bool blur_noise;\nuniform float screen_width;\nuniform float screen_height;\nuniform float distortion;\nuniform bool dof_enabled;\n\nuniform float screen_distance; \nuniform float aperture;\nuniform float darken;\nuniform float edge_blur;\nuniform bool highlights;\n\nuniform float near;\nuniform float far;\n\nvarying vec2 vUV;\n\n#define PI 3.14159265\n#define TWOPI 6.28318530\n#define inverse_focal_length 0.1 \n\nvec2 centered_screen_pos;\nvec2 distorted_coords;\nfloat radius2;\nfloat radius;\n\nvec2 rand(vec2 co)\n{\nfloat noise1=(fract(sin(dot(co,vec2(12.9898,78.233)))*43758.5453));\nfloat noise2=(fract(sin(dot(co,vec2(12.9898,78.233)*2.0))*43758.5453));\nreturn clamp(vec2(noise1,noise2),0.0,1.0);\n}\n\nvec2 getDistortedCoords(vec2 coords) {\nif (distortion == 0.0) { return coords; }\nvec2 direction=1.0*normalize(centered_screen_pos);\nvec2 dist_coords=vec2(0.5,0.5);\ndist_coords.x=0.5+direction.x*radius2*1.0;\ndist_coords.y=0.5+direction.y*radius2*1.0;\nfloat dist_amount=clamp(distortion*0.23,0.0,1.0);\ndist_coords=mix(coords,dist_coords,dist_amount);\nreturn dist_coords;\n}\n\nfloat sampleScreen(inout vec4 color,const in vec2 offset,const in float weight) {\n\nvec2 coords=distorted_coords;\nfloat angle=rand(coords*100.0).x*TWOPI;\ncoords+=vec2(offset.x*cos(angle)-offset.y*sin(angle),offset.x*sin(angle)+offset.y*cos(angle));\ncolor+=texture2D(textureSampler,coords)*weight;\nreturn weight;\n}\n\nfloat getBlurLevel(float size) {\nreturn min(3.0,ceil(size/1.0));\n}\n\nvec4 getBlurColor(float size) {\nvec4 col=texture2D(textureSampler,distorted_coords);\nif (size == 0.0) { return col; }\n\n\nfloat blur_level=getBlurLevel(size);\nfloat w=(size/screen_width);\nfloat h=(size/screen_height);\nfloat total_weight=1.0;\nvec2 sample_coords;\ntotal_weight+=sampleScreen(col,vec2(-0.50*w,0.24*h),0.93);\ntotal_weight+=sampleScreen(col,vec2(0.30*w,-0.75*h),0.90);\ntotal_weight+=sampleScreen(col,vec2(0.36*w,0.96*h),0.87);\ntotal_weight+=sampleScreen(col,vec2(-1.08*w,-0.55*h),0.85);\ntotal_weight+=sampleScreen(col,vec2(1.33*w,-0.37*h),0.83);\ntotal_weight+=sampleScreen(col,vec2(-0.82*w,1.31*h),0.80);\ntotal_weight+=sampleScreen(col,vec2(-0.31*w,-1.67*h),0.78);\ntotal_weight+=sampleScreen(col,vec2(1.47*w,1.11*h),0.76);\ntotal_weight+=sampleScreen(col,vec2(-1.97*w,0.19*h),0.74);\ntotal_weight+=sampleScreen(col,vec2(1.42*w,-1.57*h),0.72);\nif (blur_level>1.0) {\ntotal_weight+=sampleScreen(col,vec2(0.01*w,2.25*h),0.70);\ntotal_weight+=sampleScreen(col,vec2(-1.62*w,-1.74*h),0.67);\ntotal_weight+=sampleScreen(col,vec2(2.49*w,0.20*h),0.65);\ntotal_weight+=sampleScreen(col,vec2(-2.07*w,1.61*h),0.63);\ntotal_weight+=sampleScreen(col,vec2(0.46*w,-2.70*h),0.61);\ntotal_weight+=sampleScreen(col,vec2(1.55*w,2.40*h),0.59);\ntotal_weight+=sampleScreen(col,vec2(-2.88*w,-0.75*h),0.56);\ntotal_weight+=sampleScreen(col,vec2(2.73*w,-1.44*h),0.54);\ntotal_weight+=sampleScreen(col,vec2(-1.08*w,3.02*h),0.52);\ntotal_weight+=sampleScreen(col,vec2(-1.28*w,-3.05*h),0.49);\n}\nif (blur_level>2.0) {\ntotal_weight+=sampleScreen(col,vec2(3.11*w,1.43*h),0.46);\ntotal_weight+=sampleScreen(col,vec2(-3.36*w,1.08*h),0.44);\ntotal_weight+=sampleScreen(col,vec2(1.80*w,-3.16*h),0.41);\ntotal_weight+=sampleScreen(col,vec2(0.83*w,3.65*h),0.38);\ntotal_weight+=sampleScreen(col,vec2(-3.16*w,-2.19*h),0.34);\ntotal_weight+=sampleScreen(col,vec2(3.92*w,-0.53*h),0.31);\ntotal_weight+=sampleScreen(col,vec2(-2.59*w,3.12*h),0.26);\ntotal_weight+=sampleScreen(col,vec2(-0.20*w,-4.15*h),0.22);\ntotal_weight+=sampleScreen(col,vec2(3.02*w,3.00*h),0.15);\n}\ncol/=total_weight; \n\nif (darken>0.0) {\ncol.rgb*=clamp(0.3,1.0,1.05-size*0.5*darken);\n}\n\n\n\n\nreturn col;\n}\nvoid main(void)\n{\n\ncentered_screen_pos=vec2(vUV.x-0.5,vUV.y-0.5);\nradius2=centered_screen_pos.x*centered_screen_pos.x+centered_screen_pos.y*centered_screen_pos.y;\nradius=sqrt(radius2);\ndistorted_coords=getDistortedCoords(vUV); \nvec2 texels_coords=vec2(vUV.x*screen_width,vUV.y*screen_height); \nfloat depth=texture2D(depthSampler,distorted_coords).r; \nfloat distance=near+(far-near)*depth; \nvec4 color=texture2D(textureSampler,vUV); \n\n\nfloat coc=abs(aperture*(screen_distance*(inverse_focal_length-1.0/distance)-1.0));\n\nif (dof_enabled == false || coc<0.07) { coc=0.0; }\n\nfloat edge_blur_amount=0.0;\nif (edge_blur>0.0) {\nedge_blur_amount=clamp((radius*2.0-1.0+0.15*edge_blur)*1.5,0.0,1.0)*1.3;\n}\n\nfloat blur_amount=max(edge_blur_amount,coc);\n\nif (blur_amount == 0.0) {\ngl_FragColor=texture2D(textureSampler,distorted_coords);\n}\nelse {\n\ngl_FragColor=getBlurColor(blur_amount*1.7);\n\nif (highlights) {\ngl_FragColor.rgb+=clamp(coc,0.0,1.0)*texture2D(highlightsSampler,distorted_coords).rgb;\n}\nif (blur_noise) {\n\nvec2 noise=rand(distorted_coords)*0.01*blur_amount;\nvec2 blurred_coord=vec2(distorted_coords.x+noise.x,distorted_coords.y+noise.y);\ngl_FragColor=0.04*texture2D(textureSampler,blurred_coord)+0.96*gl_FragColor;\n}\n}\n\nif (grain_amount>0.0) {\nvec4 grain_color=texture2D(grainSampler,texels_coords*0.003);\ngl_FragColor.rgb+=(-0.5+grain_color.rgb)*0.30*grain_amount;\n}\n}\n",standardPixelShader:"uniform sampler2D textureSampler;\nvarying vec2 vUV;\n#if defined(PASS_POST_PROCESS)\nvoid main(void)\n{\nvec4 color=texture2D(textureSampler,vUV);\ngl_FragColor=color;\n}\n#endif\n#if defined(DOWN_SAMPLE_X4)\nuniform vec2 dsOffsets[16];\nvoid main(void)\n{\nvec4 average=vec4(0.0,0.0,0.0,0.0);\naverage=texture2D(textureSampler,vUV+dsOffsets[0]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[1]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[2]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[3]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[4]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[5]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[6]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[7]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[8]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[9]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[10]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[11]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[12]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[13]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[14]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[15]);\naverage/=16.0;\ngl_FragColor=average;\n}\n#endif\n#if defined(BRIGHT_PASS)\nuniform vec2 dsOffsets[4];\nuniform float brightThreshold;\nvoid main(void)\n{\nvec4 average=vec4(0.0,0.0,0.0,0.0);\naverage=texture2D(textureSampler,vUV+vec2(dsOffsets[0].x,dsOffsets[0].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[1].x,dsOffsets[1].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[2].x,dsOffsets[2].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[3].x,dsOffsets[3].y));\naverage*=0.25;\nfloat luminance=length(average.rgb);\nif (luminanceshadowPixelDepth)\naccumFog+=sunColor*computeScattering(dot(rayDirection,sunDirection));\ncurrentPosition+=stepL;\n}\naccumFog/=NB_STEPS;\nvec3 color=accumFog*scatteringPower;\ngl_FragColor=vec4(color*exp(color) ,1.0);\n}\n#endif\n#if defined(VLSMERGE)\nuniform sampler2D originalSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(originalSampler,vUV)+texture2D(textureSampler,vUV);\n}\n#endif\n#if defined(LUMINANCE)\nuniform vec2 lumOffsets[4];\nvoid main()\n{\nfloat average=0.0;\nvec4 color=vec4(0.0);\nfloat maximum=-1e20;\nvec3 weight=vec3(0.299,0.587,0.114);\nfor (int i=0; i<4; i++)\n{\ncolor=texture2D(textureSampler,vUV+ lumOffsets[i]);\n\nfloat GreyValue=dot(color.rgb,vec3(0.33,0.33,0.33));\n\n#ifdef WEIGHTED_AVERAGE\nfloat GreyValue=dot(color.rgb,weight);\n#endif\n#ifdef BRIGHTNESS\nfloat GreyValue=max(color.r,max(color.g,color.b));\n#endif\n#ifdef HSL_COMPONENT\nfloat GreyValue=0.5*(max(color.r,max(color.g,color.b))+min(color.r,min(color.g,color.b)));\n#endif\n#ifdef MAGNITUDE\nfloat GreyValue=length(color.rgb);\n#endif\nmaximum=max(maximum,GreyValue);\naverage+=(0.25*log(1e-5+GreyValue));\n}\naverage=exp(average);\ngl_FragColor=vec4(average,maximum,0.0,1.0);\n}\n#endif\n#if defined(LUMINANCE_DOWN_SAMPLE)\nuniform vec2 dsOffsets[9];\nuniform float halfDestPixelSize;\n#ifdef FINAL_DOWN_SAMPLER\nvec4 pack(float value) {\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(value*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\n#endif\nvoid main()\n{\nvec4 color=vec4(0.0);\nfloat average=0.0;\nfor (int i=0; i<9; i++)\n{\ncolor=texture2D(textureSampler,vUV+vec2(halfDestPixelSize,halfDestPixelSize)+dsOffsets[i]);\naverage+=color.r;\n}\naverage/=9.0;\n#ifdef FINAL_DOWN_SAMPLER\ngl_FragColor=pack(average);\n#else\ngl_FragColor=vec4(average,average,0.0,1.0);\n#endif\n}\n#endif\n#if defined(HDR)\nuniform sampler2D textureAdderSampler;\nuniform float averageLuminance;\nvoid main()\n{\nvec4 color=texture2D(textureAdderSampler,vUV);\nvec4 adjustedColor=color/averageLuminance;\ncolor=adjustedColor;\ncolor.a=1.0;\ngl_FragColor=color;\n}\n#endif\n#if defined(LENS_FLARE)\n#define GHOSTS 3\nuniform sampler2D lensColorSampler;\nuniform float strength;\nuniform float ghostDispersal;\nuniform float haloWidth;\nuniform vec2 resolution;\nuniform float distortionStrength;\nfloat hash(vec2 p)\n{\nfloat h=dot(p,vec2(127.1,311.7));\nreturn -1.0+2.0*fract(sin(h)*43758.5453123);\n}\nfloat noise(in vec2 p)\n{\nvec2 i=floor(p);\nvec2 f=fract(p);\nvec2 u=f*f*(3.0-2.0*f);\nreturn mix(mix(hash(i+vec2(0.0,0.0)),\nhash(i+vec2(1.0,0.0)),u.x),\nmix(hash(i+vec2(0.0,1.0)),\nhash(i+vec2(1.0,1.0)),u.x),u.y);\n}\nfloat fbm(vec2 p)\n{\nfloat f=0.0;\nf+=0.5000*noise(p); p*=2.02;\nf+=0.2500*noise(p); p*=2.03;\nf+=0.1250*noise(p); p*=2.01;\nf+=0.0625*noise(p); p*=2.04;\nf/=0.9375;\nreturn f;\n}\nvec3 pattern(vec2 uv)\n{\nvec2 p=-1.0+2.0*uv;\nfloat p2=dot(p,p);\nfloat f=fbm(vec2(15.0*p2))/2.0;\nfloat r=0.2+0.6*sin(12.5*length(uv-vec2(0.5)));\nfloat g=0.2+0.6*sin(20.5*length(uv-vec2(0.5)));\nfloat b=0.2+0.6*sin(17.2*length(uv-vec2(0.5)));\nreturn (1.0-f)*vec3(r,g,b);\n}\nfloat luminance(vec3 color)\n{\nreturn dot(color.rgb,vec3(0.2126,0.7152,0.0722));\n}\nvec4 textureDistorted(sampler2D tex,vec2 texcoord,vec2 direction,vec3 distortion)\n{\nreturn vec4(\ntexture2D(tex,texcoord+direction*distortion.r).r,\ntexture2D(tex,texcoord+direction*distortion.g).g,\ntexture2D(tex,texcoord+direction*distortion.b).b,\n1.0\n);\n}\nvoid main(void)\n{\nvec2 uv=-vUV+vec2(1.0);\nvec2 ghostDir=(vec2(0.5)-uv)*ghostDispersal;\nvec2 texelSize=1.0/resolution;\nvec3 distortion=vec3(-texelSize.x*distortionStrength,0.0,texelSize.x*distortionStrength);\nvec4 result=vec4(0.0);\nfloat ghostIndice=1.0;\nfor (int i=0; i=nSamples)\nbreak;\nvec2 offset1=vUV+velocity*(float(i)/float(nSamples-1)-0.5);\nresult+=texture2D(textureSampler,offset1);\n}\ngl_FragColor=result/float(nSamples);\n}\n#endif\n",fxaaVertexShader:"\nattribute vec2 position;\nuniform vec2 texelSize;\n\nvarying vec2 vUV;\nvarying vec2 sampleCoordS;\nvarying vec2 sampleCoordE;\nvarying vec2 sampleCoordN;\nvarying vec2 sampleCoordW;\nvarying vec2 sampleCoordNW;\nvarying vec2 sampleCoordSE;\nvarying vec2 sampleCoordNE;\nvarying vec2 sampleCoordSW;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nvUV=(position*madd+madd);\nsampleCoordS=vUV+vec2( 0.0,1.0)*texelSize;\nsampleCoordE=vUV+vec2( 1.0,0.0)*texelSize;\nsampleCoordN=vUV+vec2( 0.0,-1.0)*texelSize;\nsampleCoordW=vUV+vec2(-1.0,0.0)*texelSize;\nsampleCoordNW=vUV+vec2(-1.0,-1.0)*texelSize;\nsampleCoordSE=vUV+vec2( 1.0,1.0)*texelSize;\nsampleCoordNE=vUV+vec2( 1.0,-1.0)*texelSize;\nsampleCoordSW=vUV+vec2(-1.0,1.0)*texelSize;\ngl_Position=vec4(position,0.0,1.0);\n}", fxaaPixelShader:"uniform sampler2D textureSampler;\nuniform vec2 texelSize;\nvarying vec2 vUV;\nvarying vec2 sampleCoordS;\nvarying vec2 sampleCoordE;\nvarying vec2 sampleCoordN;\nvarying vec2 sampleCoordW;\nvarying vec2 sampleCoordNW;\nvarying vec2 sampleCoordSE;\nvarying vec2 sampleCoordNE;\nvarying vec2 sampleCoordSW;\nconst float fxaaQualitySubpix=1.0;\nconst float fxaaQualityEdgeThreshold=0.166;\nconst float fxaaQualityEdgeThresholdMin=0.0833;\nconst vec3 kLumaCoefficients=vec3(0.2126,0.7152,0.0722);\n#define FxaaLuma(rgba) dot(rgba.rgb,kLumaCoefficients)\nvoid main(){\nvec2 posM;\nposM.x=vUV.x;\nposM.y=vUV.y;\nvec4 rgbyM=texture2D(textureSampler,vUV,0.0);\nfloat lumaM=FxaaLuma(rgbyM);\nfloat lumaS=FxaaLuma(texture2D(textureSampler,sampleCoordS,0.0));\nfloat lumaE=FxaaLuma(texture2D(textureSampler,sampleCoordE,0.0));\nfloat lumaN=FxaaLuma(texture2D(textureSampler,sampleCoordN,0.0));\nfloat lumaW=FxaaLuma(texture2D(textureSampler,sampleCoordW,0.0));\nfloat maxSM=max(lumaS,lumaM);\nfloat minSM=min(lumaS,lumaM);\nfloat maxESM=max(lumaE,maxSM);\nfloat minESM=min(lumaE,minSM);\nfloat maxWN=max(lumaN,lumaW);\nfloat minWN=min(lumaN,lumaW);\nfloat rangeMax=max(maxWN,maxESM);\nfloat rangeMin=min(minWN,minESM);\nfloat rangeMaxScaled=rangeMax*fxaaQualityEdgeThreshold;\nfloat range=rangeMax-rangeMin;\nfloat rangeMaxClamped=max(fxaaQualityEdgeThresholdMin,rangeMaxScaled);\nif(range=edgeVert;\nfloat subpixA=subpixNSWE*2.0+subpixNWSWNESE;\nif (!horzSpan)\n{\nlumaN=lumaW;\n}\nif (!horzSpan) \n{\nlumaS=lumaE;\n}\nif (horzSpan) \n{\nlengthSign=texelSize.y;\n}\nfloat subpixB=(subpixA*(1.0/12.0))-lumaM;\nfloat gradientN=lumaN-lumaM;\nfloat gradientS=lumaS-lumaM;\nfloat lumaNN=lumaN+lumaM;\nfloat lumaSS=lumaS+lumaM;\nbool pairN=abs(gradientN)>=abs(gradientS);\nfloat gradient=max(abs(gradientN),abs(gradientS));\nif (pairN)\n{\nlengthSign=-lengthSign;\n}\nfloat subpixC=clamp(abs(subpixB)*subpixRcpRange,0.0,1.0);\nvec2 posB;\nposB.x=posM.x;\nposB.y=posM.y;\nvec2 offNP;\noffNP.x=(!horzSpan) ? 0.0 : texelSize.x;\noffNP.y=(horzSpan) ? 0.0 : texelSize.y;\nif (!horzSpan) \n{\nposB.x+=lengthSign*0.5;\n}\nif (horzSpan)\n{\nposB.y+=lengthSign*0.5;\n}\nvec2 posN;\nposN.x=posB.x-offNP.x*1.5;\nposN.y=posB.y-offNP.y*1.5;\nvec2 posP;\nposP.x=posB.x+offNP.x*1.5;\nposP.y=posB.y+offNP.y*1.5;\nfloat subpixD=((-2.0)*subpixC)+3.0;\nfloat lumaEndN=FxaaLuma(texture2D(textureSampler,posN,0.0));\nfloat subpixE=subpixC*subpixC;\nfloat lumaEndP=FxaaLuma(texture2D(textureSampler,posP,0.0));\nif (!pairN) \n{\nlumaNN=lumaSS;\n}\nfloat gradientScaled=gradient*1.0/4.0;\nfloat lumaMM=lumaM-lumaNN*0.5;\nfloat subpixF=subpixD*subpixE;\nbool lumaMLTZero=lumaMM<0.0;\nlumaEndN-=lumaNN*0.5;\nlumaEndP-=lumaNN*0.5;\nbool doneN=abs(lumaEndN)>=gradientScaled;\nbool doneP=abs(lumaEndP)>=gradientScaled;\nif (!doneN) \n{\nposN.x-=offNP.x*3.0;\n}\nif (!doneN) \n{\nposN.y-=offNP.y*3.0;\n}\nbool doneNP=(!doneN) || (!doneP);\nif (!doneP) \n{\nposP.x+=offNP.x*3.0;\n}\nif (!doneP)\n{\nposP.y+=offNP.y*3.0;\n}\nif (doneNP)\n{\nif (!doneN) lumaEndN=FxaaLuma(texture2D(textureSampler,posN.xy,0.0));\nif (!doneP) lumaEndP=FxaaLuma(texture2D(textureSampler,posP.xy,0.0));\nif (!doneN) lumaEndN=lumaEndN-lumaNN*0.5;\nif (!doneP) lumaEndP=lumaEndP-lumaNN*0.5;\ndoneN=abs(lumaEndN)>=gradientScaled;\ndoneP=abs(lumaEndP)>=gradientScaled;\nif (!doneN) posN.x-=offNP.x*12.0;\nif (!doneN) posN.y-=offNP.y*12.0;\ndoneNP=(!doneN) || (!doneP);\nif (!doneP) posP.x+=offNP.x*12.0;\nif (!doneP) posP.y+=offNP.y*12.0;\n}\nfloat dstN=posM.x-posN.x;\nfloat dstP=posP.x-posM.x;\nif (!horzSpan)\n{\ndstN=posM.y-posN.y;\n}\nif (!horzSpan) \n{\ndstP=posP.y-posM.y;\n}\nbool goodSpanN=(lumaEndN<0.0) != lumaMLTZero;\nfloat spanLength=(dstP+dstN);\nbool goodSpanP=(lumaEndP<0.0) != lumaMLTZero;\nfloat spanLengthRcp=1.0/spanLength;\nbool directionN=dstN\n#include\nattribute vec3 position;\nattribute vec3 normal;\n#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nvarying vec2 uv;\n#endif\n#ifdef UV2\nvarying vec2 uv2;\n#endif\n#endif\n\nuniform mat4 viewProjection;\nuniform mat4 view;\nvarying vec3 vNormalV;\nvarying vec4 vViewPos;\n#ifdef POSITION\nvarying vec3 vPosition;\n#endif\nvoid main(void)\n{\n#include\n#include\nvec4 pos=vec4(finalWorld*vec4(position,1.0));\nvNormalV=normalize(vec3((view*finalWorld)*vec4(normal,0.0)));\nvViewPos=view*pos;\n#ifdef POSITION\nvPosition=pos.xyz/pos.w;\n#endif\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}",geometryPixelShader:"#extension GL_EXT_draw_buffers : require\nprecision highp float;\nprecision highp int;\nvarying vec3 vNormalV;\nvarying vec4 vViewPos;\n#ifdef POSITION\nvarying vec3 vPosition;\n#endif\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef POSITION\n#include[3]\n#else\n#include[2]\n#endif\nvoid main() {\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\ngl_FragData[0]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);\n\ngl_FragData[1]=vec4(normalize(vNormalV),1.0);\n\n#ifdef POSITION\ngl_FragData[2]=vec4(vPosition,1.0);\n#endif\n}",refractionPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D refractionSampler;\n\nuniform vec3 baseColor;\nuniform float depth;\nuniform float colorLevel;\nvoid main() {\nfloat ref=1.0-texture2D(refractionSampler,vUV).r;\nvec2 uv=vUV-vec2(0.5);\nvec2 offset=uv*depth*ref;\nvec3 sourceColor=texture2D(textureSampler,vUV-offset).rgb;\ngl_FragColor=vec4(sourceColor+sourceColor*ref*colorLevel,1.0);\n}",blackAndWhitePixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform float degree;\nvoid main(void) \n{\nvec3 color=texture2D(textureSampler,vUV).rgb;\nfloat luminance=dot(color,vec3(0.3,0.59,0.11)); \nvec3 blackAndWhite=vec3(luminance,luminance,luminance);\ngl_FragColor=vec4(color-((color-blackAndWhite)*degree),1.0);\n}",convolutionPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 screenSize;\nuniform float kernel[9];\nvoid main(void)\n{\nvec2 onePixel=vec2(1.0,1.0)/screenSize;\nvec4 colorSum =\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,-1))*kernel[0] +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,-1))*kernel[1] +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,-1))*kernel[2] +\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,0))*kernel[3] +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,0))*kernel[4] +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,0))*kernel[5] +\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,1))*kernel[6] +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,1))*kernel[7] +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,1))*kernel[8];\nfloat kernelWeight =\nkernel[0] +\nkernel[1] +\nkernel[2] +\nkernel[3] +\nkernel[4] +\nkernel[5] +\nkernel[6] +\nkernel[7] +\nkernel[8];\nif (kernelWeight<=0.0) {\nkernelWeight=1.0;\n}\ngl_FragColor=vec4((colorSum/kernelWeight).rgb,1);\n}",filterPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform mat4 kernelMatrix;\nvoid main(void)\n{\nvec3 baseColor=texture2D(textureSampler,vUV).rgb;\nvec3 updatedColor=(kernelMatrix*vec4(baseColor,1.0)).rgb;\ngl_FragColor=vec4(updatedColor,1.0);\n}",volumetricLightScatteringPixelShader:"uniform sampler2D textureSampler;\nuniform sampler2D lightScatteringSampler;\nuniform float decay;\nuniform float exposure;\nuniform float weight;\nuniform float density;\nuniform vec2 meshPositionOnScreen;\nvarying vec2 vUV;\nvoid main(void) {\nvec2 tc=vUV;\nvec2 deltaTexCoord=(tc-meshPositionOnScreen.xy);\ndeltaTexCoord*=1.0/float(NUM_SAMPLES)*density;\nfloat illuminationDecay=1.0;\nvec4 color=texture2D(lightScatteringSampler,tc)*0.4;\nfor(int i=0; i\n#include\n#include\nvoid main(void)\n{\nvec4 result=texture2D(textureSampler,vUV);\n#ifdef IMAGEPROCESSING\n#ifndef FROMLINEARSPACE\n\nresult.rgb=toLinearSpace(result.rgb);\n#endif\nresult=applyImageProcessing(result);\n#else\n\n#ifdef FROMLINEARSPACE\nresult=applyImageProcessing(result);\n#endif\n#endif\ngl_FragColor=result;\n}",kernelBlurVertexShader:"\nattribute vec2 position;\n\nuniform vec2 delta;\n\nvarying vec2 sampleCenter;\n#include[0..varyingCount]\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nsampleCenter=(position*madd+madd);\n#include[0..varyingCount]\ngl_Position=vec4(position,0.0,1.0);\n}",kernelBlurPixelShader:"\nuniform sampler2D textureSampler;\nuniform vec2 delta;\n\nvarying vec2 sampleCenter;\n#include[0..varyingCount]\n#ifdef PACKEDFLOAT\nvec4 pack(float depth)\n{\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(depth*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}\n#endif\nvoid main(void)\n{\n#ifdef PACKEDFLOAT \nfloat blend=0.;\n#else\nvec4 blend=vec4(0.);\n#endif\n#include[0..varyingCount]\n#include[0..depCount]\n#ifdef PACKEDFLOAT\ngl_FragColor=pack(blend);\n#else\ngl_FragColor=blend;\n#endif\n}",lensFlareVertexShader:"\nattribute vec2 position;\n\nuniform mat4 viewportMatrix;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nvUV=position*madd+madd;\ngl_Position=viewportMatrix*vec4(position,0.0,1.0);\n}",lensFlarePixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec4 color;\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\ngl_FragColor=baseColor*color;\n}",anaglyphPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D leftSampler;\nvoid main(void)\n{\nvec4 leftFrag=texture2D(leftSampler,vUV);\nleftFrag=vec4(1.0,leftFrag.g,leftFrag.b,1.0);\nvec4 rightFrag=texture2D(textureSampler,vUV);\nrightFrag=vec4(rightFrag.r,1.0,1.0,1.0);\ngl_FragColor=vec4(rightFrag.rgb*leftFrag.rgb,1.0);\n}",stereoscopicInterlacePixelShader:"const vec3 TWO=vec3(2.0,2.0,2.0);\nvarying vec2 vUV;\nuniform sampler2D camASampler;\nuniform sampler2D textureSampler;\nuniform vec2 stepSize;\nvoid main(void)\n{\nbool useCamB;\nvec2 texCoord1;\nvec2 texCoord2;\nvec3 frag1;\nvec3 frag2;\n#ifdef IS_STEREOSCOPIC_HORIZ\nuseCamB=vUV.x>0.5;\ntexCoord1=vec2(useCamB ? (vUV.x-0.5)*2.0 : vUV.x*2.0,vUV.y);\ntexCoord2=vec2(texCoord1.x+stepSize.x,vUV.y);\n#else\nuseCamB=vUV.y>0.5;\ntexCoord1=vec2(vUV.x,useCamB ? (vUV.y-0.5)*2.0 : vUV.y*2.0);\ntexCoord2=vec2(vUV.x,texCoord1.y+stepSize.y);\n#endif\n\nif (useCamB){\nfrag1=texture2D(textureSampler,texCoord1).rgb;\nfrag2=texture2D(textureSampler,texCoord2).rgb;\n}else{\nfrag1=texture2D(camASampler ,texCoord1).rgb;\nfrag2=texture2D(camASampler ,texCoord2).rgb;\n}\ngl_FragColor=vec4((frag1+frag2)/TWO,1.0);\n}",vrDistortionCorrectionPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 LensCenter;\nuniform vec2 Scale;\nuniform vec2 ScaleIn;\nuniform vec4 HmdWarpParam;\nvec2 HmdWarp(vec2 in01) {\nvec2 theta=(in01-LensCenter)*ScaleIn; \nfloat rSq=theta.x*theta.x+theta.y*theta.y;\nvec2 rvector=theta*(HmdWarpParam.x+HmdWarpParam.y*rSq+HmdWarpParam.z*rSq*rSq+HmdWarpParam.w*rSq*rSq*rSq);\nreturn LensCenter+Scale*rvector;\n}\nvoid main(void)\n{\nvec2 tc=HmdWarp(vUV);\nif (tc.x <0.0 || tc.x>1.0 || tc.y<0.0 || tc.y>1.0)\ngl_FragColor=vec4(0.0,0.0,0.0,0.0);\nelse{\ngl_FragColor=texture2D(textureSampler,tc);\n}\n}",glowBlurPostProcessPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec2 screenSize;\nuniform vec2 direction;\nuniform float blurWidth;\n\nfloat getLuminance(vec3 color)\n{\nreturn dot(color,vec3(0.2126,0.7152,0.0722));\n}\nvoid main(void)\n{\nfloat weights[7];\nweights[0]=0.05;\nweights[1]=0.1;\nweights[2]=0.2;\nweights[3]=0.3;\nweights[4]=0.2;\nweights[5]=0.1;\nweights[6]=0.05;\nvec2 texelSize=vec2(1.0/screenSize.x,1.0/screenSize.y);\nvec2 texelStep=texelSize*direction*blurWidth;\nvec2 start=vUV-3.0*texelStep;\nvec4 baseColor=vec4(0.,0.,0.,0.);\nvec2 texelOffset=vec2(0.,0.);\nfor (int i=0; i<7; i++)\n{\n\nvec4 texel=texture2D(textureSampler,start+texelOffset);\nbaseColor.a+=texel.a*weights[i];\n\nfloat luminance=getLuminance(baseColor.rgb);\nfloat luminanceTexel=getLuminance(texel.rgb);\nfloat choice=step(luminanceTexel,luminance);\nbaseColor.rgb=choice*baseColor.rgb+(1.0-choice)*texel.rgb;\ntexelOffset+=texelStep;\n}\ngl_FragColor=baseColor;\n}",glowMapGenerationPixelShader:"#ifdef ALPHATEST\nvarying vec2 vUVDiffuse;\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform sampler2D emissiveSampler;\n#endif\nuniform vec4 color;\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUVDiffuse).a<0.4)\ndiscard;\n#endif\n#ifdef EMISSIVE\ngl_FragColor=texture2D(emissiveSampler,vUVEmissive);\n#else\ngl_FragColor=color;\n#endif\n}",glowMapGenerationVertexShader:"\nattribute vec3 position;\n#include\n\n#include\nuniform mat4 viewProjection;\nvarying vec4 vPosition;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef ALPHATEST\nvarying vec2 vUVDiffuse;\nuniform mat4 diffuseMatrix;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform mat4 emissiveMatrix;\n#endif\nvoid main(void)\n{\n#include\n#include\n#ifdef CUBEMAP\nvPosition=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#else\nvPosition=viewProjection*finalWorld*vec4(position,1.0);\ngl_Position=vPosition;\n#endif\n#ifdef ALPHATEST\n#ifdef DIFFUSEUV1\nvUVDiffuse=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef DIFFUSEUV2\nvUVDiffuse=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef EMISSIVE\n#ifdef EMISSIVEUV1\nvUVEmissive=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef EMISSIVEUV2\nvUVEmissive=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}",glowMapMergePixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform float offset;\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\nbaseColor.a=abs(offset-baseColor.a);\ngl_FragColor=baseColor;\n}",glowMapMergeVertexShader:"\nattribute vec2 position;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nvUV=position*madd+madd;\ngl_Position=vec4(position,0.0,1.0);\n}",lineVertexShader:"\nattribute vec3 position;\nattribute vec4 normal;\n\nuniform mat4 worldViewProjection;\nuniform float width;\nuniform float aspectRatio;\nvoid main(void) {\nvec4 viewPosition=worldViewProjection*vec4(position,1.0);\nvec4 viewPositionNext=worldViewProjection*vec4(normal.xyz,1.0);\nvec2 currentScreen=viewPosition.xy/viewPosition.w;\nvec2 nextScreen=viewPositionNext.xy/viewPositionNext.w;\ncurrentScreen.x*=aspectRatio;\nnextScreen.x*=aspectRatio;\nvec2 dir=normalize(nextScreen-currentScreen);\nvec2 normalDir=vec2(-dir.y,dir.x);\nnormalDir*=width/2.0;\nnormalDir.x/=aspectRatio;\nvec4 offset=vec4(normalDir*normal.w,0.0,0.0);\ngl_Position=viewPosition+offset;\n}",linePixelShader:"uniform vec4 color;\nvoid main(void) {\ngl_FragColor=color;\n}",outlineVertexShader:"\nattribute vec3 position;\nattribute vec3 normal;\n#include\n\nuniform float offset;\n#include\nuniform mat4 viewProjection;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n#include\nvoid main(void)\n{\nvec3 offsetPosition=position+normal*offset;\n#include\n#include\ngl_Position=viewProjection*finalWorld*vec4(offsetPosition,1.0);\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#include\n}\n",outlinePixelShader:"#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nuniform vec4 color;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\n#include\nvoid main(void) {\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\n#include\ngl_FragColor=color;\n}",layerVertexShader:"\nattribute vec2 position;\n\nuniform vec2 scale;\nuniform vec2 offset;\nuniform mat4 textureMatrix;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nvec2 shiftedPosition=position*scale+offset;\nvUV=vec2(textureMatrix*vec4(shiftedPosition*madd+madd,1.0,0.0));\ngl_Position=vec4(shiftedPosition,0.0,1.0);\n}",layerPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec4 color;\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\ngl_FragColor=baseColor*color;\n}",backgroundVertexShader:"precision highp float;\n#include<__decl__backgroundVertex>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include\n\n#include\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2; \n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nvarying vec2 vDiffuseUV;\n#endif\n#include\n#include\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\nvoid main(void) {\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=position;\n#endif \n#include\n#include\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normal);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(position,0.0)));\n#endif\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif \n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0 \nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include\n\n#include\n\n#include[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n",backgroundPixelShader:"#ifdef TEXTURELODSUPPORT\n#extension GL_EXT_shader_texture_lod : enable\n#endif\nprecision highp float;\n#include<__decl__backgroundFragment>\n\nuniform vec3 vEyePosition;\n\nvarying vec3 vPositionW;\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif \n#ifdef MAINUV2 \nvarying vec2 vMainUV2; \n#endif \n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include\n#endif\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n\n#ifndef SHADOWONLY\n#define SHADOWONLY;\n#endif\n#include\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include\n#include\n#include\n#include\n#include\n\n#include\n#ifdef REFLECTIONFRESNEL\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\nvec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow(clamp(1.0-VdotN,0.,1.),5.0);\n}\n#endif\nvoid main(void) {\n#include\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(0.0,1.0,0.0);\n#endif\n\nfloat shadow=1.;\nfloat globalShadow=0.;\nfloat shadowLightCount=0.;\n#include[0..maxSimultaneousLights]\n#ifdef SHADOWINUSE\nglobalShadow/=shadowLightCount;\n#else\nglobalShadow=1.0;\n#endif\n\nvec3 reflectionColor=vec3(1.,1.,1.);\n#ifdef REFLECTION\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#ifdef REFLECTIONBLUR\nfloat reflectionLOD=vReflectionInfos.y;\n#ifdef TEXTURELODSUPPORT\n\nreflectionLOD=reflectionLOD*log2(vReflectionMicrosurfaceInfos.x)*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nreflectionColor=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD).rgb;\n#else\nfloat lodReflectionNormalized=clamp(reflectionLOD,0.,1.);\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec3 reflectionSpecularMid=sampleReflection(reflectionSampler,reflectionCoords).rgb;\nif(lodReflectionNormalizedDoubled<1.0){\nreflectionColor=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords).rgb,\nreflectionSpecularMid,\nlodReflectionNormalizedDoubled\n);\n} else {\nreflectionColor=mix(\nreflectionSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords).rgb,\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#else\nvec4 reflectionSample=sampleReflection(reflectionSampler,reflectionCoords);\nreflectionColor=reflectionSample.rgb;\n#endif\n#ifdef GAMMAREFLECTION\nreflectionColor=toLinearSpace(reflectionColor.rgb);\n#endif\n\nreflectionColor*=vReflectionInfos.x;\n#endif\n\nvec3 diffuseColor=vec3(1.,1.,1.);\nfloat finalAlpha=alpha;\n#ifdef DIFFUSE\nvec4 diffuseMap=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef GAMMADIFFUSE\ndiffuseMap.rgb=toLinearSpace(diffuseMap.rgb);\n#endif\n\ndiffuseMap.rgb*=vDiffuseInfos.y;\n#ifdef DIFFUSEHASALPHA\nfinalAlpha*=diffuseMap.a;\n#endif\ndiffuseColor=diffuseMap.rgb;\n#endif\n\n#ifdef REFLECTIONFRESNEL\nvec3 colorBase=diffuseColor;\n#else\nvec3 colorBase=reflectionColor*diffuseColor;\n#endif\ncolorBase=max(colorBase,0.0);\n\n#ifdef USERGBCOLOR\nvec3 finalColor=colorBase;\n#else\nvec3 finalColor=colorBase.r*vPrimaryColor.rgb*vPrimaryColor.a;\nfinalColor+=colorBase.g*vSecondaryColor.rgb*vSecondaryColor.a;\nfinalColor+=colorBase.b*vTertiaryColor.rgb*vTertiaryColor.a;\n#endif\n\n#ifdef REFLECTIONFRESNEL\nvec3 reflectionAmount=vReflectionControl.xxx;\nvec3 reflectionReflectance0=vReflectionControl.yyy;\nvec3 reflectionReflectance90=vReflectionControl.zzz;\nfloat VdotN=dot(normalize(vEyePosition),normalW);\nvec3 planarReflectionFresnel=fresnelSchlickEnvironmentGGX(clamp(VdotN,0.0,1.0),reflectionReflectance0,reflectionReflectance90,1.0);\nreflectionAmount*=planarReflectionFresnel;\n#ifdef REFLECTIONFALLOFF\nfloat reflectionDistanceFalloff=1.0-clamp(length(vPositionW.xyz-vBackgroundCenter)*vReflectionControl.w,0.0,1.0);\nreflectionDistanceFalloff*=reflectionDistanceFalloff;\nreflectionAmount*=reflectionDistanceFalloff;\n#endif\nfinalColor=mix(finalColor,reflectionColor,clamp(reflectionAmount,0.,1.));\n#endif\n#ifdef OPACITYFRESNEL\nfloat viewAngleToFloor=dot(normalW,normalize(vEyePosition-vBackgroundCenter));\n\nconst float startAngle=0.1;\nfloat fadeFactor=clamp(viewAngleToFloor/startAngle,0.0,1.0);\nfinalAlpha*=fadeFactor*fadeFactor;\n#endif\n\n#ifdef SHADOWINUSE\nfinalColor=mix(finalColor*shadowLevel,finalColor,globalShadow);\n#endif\n\nvec4 color=vec4(finalColor,finalAlpha);\n#include\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\ncolor.rgb=clamp(color.rgb,0.,30.0);\n#else\n\ncolor=applyImageProcessing(color);\n#endif\n#ifdef PREMULTIPLYALPHA\n\ncolor.rgb*=color.a;\n#endif\n#ifdef NOISE\ncolor.rgb=dither(vPositionW.xy,color.rgb);\n#endif\ngl_FragColor=color;\n}"},BABYLON.Effect.IncludesShadersStore={depthPrePass:"#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif",bonesDeclaration:"#if NUM_BONE_INFLUENCERS>0\nuniform mat4 mBones[BonesPerMesh];\nattribute vec4 matricesIndices;\nattribute vec4 matricesWeights;\n#if NUM_BONE_INFLUENCERS>4\nattribute vec4 matricesIndicesExtra;\nattribute vec4 matricesWeightsExtra;\n#endif\n#endif",instancesDeclaration:"#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#else\nuniform mat4 world;\n#endif",pointCloudVertexDeclaration:"#ifdef POINTSIZE\nuniform float pointSize;\n#endif",bumpVertexDeclaration:"#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL) \nvarying mat3 vTBN;\n#endif\n#endif\n",clipPlaneVertexDeclaration:"#ifdef CLIPPLANE\nuniform vec4 vClipPlane;\nvarying float fClipDistance;\n#endif",fogVertexDeclaration:"#ifdef FOG\nvarying vec3 vFogDistance;\n#endif",morphTargetsVertexGlobalDeclaration:"#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif", morphTargetsVertexDeclaration:"#ifdef MORPHTARGETS\nattribute vec3 position{X};\n#ifdef MORPHTARGETS_NORMAL\nattribute vec3 normal{X};\n#endif\n#ifdef MORPHTARGETS_TANGENT\nattribute vec3 tangent{X};\n#endif\n#endif",logDepthDeclaration:"#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif",morphTargetsVertex:"#ifdef MORPHTARGETS\npositionUpdated+=(position{X}-position)*morphTargetInfluences[{X}];\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated+=(normal{X}-normal)*morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz+=(tangent{X}-tangent.xyz)*morphTargetInfluences[{X}];\n#endif\n#endif",instancesVertex:"#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif",bonesVertex:"#if NUM_BONE_INFLUENCERS>0\nmat4 influence;\ninfluence=mBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence+=mBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif \n#if NUM_BONE_INFLUENCERS>2\ninfluence+=mBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif \n#if NUM_BONE_INFLUENCERS>3\ninfluence+=mBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif \n#if NUM_BONE_INFLUENCERS>4\ninfluence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif \n#if NUM_BONE_INFLUENCERS>5\ninfluence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif \n#if NUM_BONE_INFLUENCERS>6\ninfluence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif \n#if NUM_BONE_INFLUENCERS>7\ninfluence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif \nfinalWorld=finalWorld*influence;\n#endif",bumpVertex:"#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL)\nvec3 tbnNormal=normalize(normalUpdated);\nvec3 tbnTangent=normalize(tangentUpdated.xyz);\nvec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;\nvTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal);\n#endif\n#endif",clipPlaneVertex:"#ifdef CLIPPLANE\nfClipDistance=dot(worldPos,vClipPlane);\n#endif",fogVertex:"#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif",shadowsVertex:"#ifdef SHADOWS\n#if defined(SHADOW{X}) && !defined(SHADOWCUBE{X})\nvPositionFromLight{X}=lightMatrix{X}*worldPos;\nvDepthMetric{X}=((vPositionFromLight{X}.z+light{X}.depthValues.x)/(light{X}.depthValues.y));\n#endif\n#endif",pointCloudVertex:"#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif",logDepthVertex:"#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif",helperFunctions:"const float PI=3.1415926535897932384626433832795;\nconst float LinearEncodePowerApprox=2.2;\nconst float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;\nconst vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);\nmat3 transposeMat3(mat3 inMatrix) {\nvec3 i0=inMatrix[0];\nvec3 i1=inMatrix[1];\nvec3 i2=inMatrix[2];\nmat3 outMatrix=mat3(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);\nreturn outMatrix;\n}\n\nmat3 inverseMat3(mat3 inMatrix) {\nfloat a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];\nfloat a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];\nfloat a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];\nfloat b01=a22*a11-a12*a21;\nfloat b11=-a22*a10+a12*a20;\nfloat b21=a21*a10-a11*a20;\nfloat det=a00*b01+a01*b11+a02*b21;\nreturn mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),\nb11,(a22*a00-a02*a20),(-a12*a00+a02*a10),\nb21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;\n}\nfloat computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)\n{\nfloat mask=smoothstep(1.0-frustumEdgeFalloff,1.0,clamp(dot(clipSpace,clipSpace),0.,1.));\nreturn mix(value,1.0,mask);\n}\nvec3 applyEaseInOut(vec3 x){\nreturn x*x*(3.0-2.0*x);\n}\nvec3 toLinearSpace(vec3 color)\n{\nreturn pow(color,vec3(LinearEncodePowerApprox));\n}\nvec3 toGammaSpace(vec3 color)\n{\nreturn pow(color,vec3(GammaEncodePowerApprox));\n}\nfloat square(float value)\n{\nreturn value*value;\n}\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,LuminanceEncodeApprox),0.,1.);\n}\n\nfloat getRand(vec2 seed) {\nreturn fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);\n}\nvec3 dither(vec2 seed,vec3 color) {\nfloat rand=getRand(seed);\ncolor.rgb+=mix(-0.5/255.0,0.5/255.0,rand);\nreturn color;\n}",lightFragmentDeclaration:"#ifdef LIGHT{X}\nuniform vec4 vLightData{X};\nuniform vec4 vLightDiffuse{X};\n#ifdef SPECULARTERM\nuniform vec3 vLightSpecular{X};\n#else\nvec3 vLightSpecular{X}=vec3(0.);\n#endif\n#ifdef SHADOW{X}\n#if defined(SHADOWCUBE{X})\nuniform samplerCube shadowSampler{X};\n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\nuniform sampler2D shadowSampler{X};\nuniform mat4 lightMatrix{X};\n#endif\nuniform vec4 shadowsInfo{X};\nuniform vec2 depthValues{X};\n#endif\n#ifdef SPOTLIGHT{X}\nuniform vec4 vLightDirection{X};\n#endif\n#ifdef HEMILIGHT{X}\nuniform vec3 vLightGround{X};\n#endif\n#endif",lightsFragmentFunctions:"\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef NDOTL\nfloat ndl;\n#endif\n};\nlightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {\nlightingInfo result;\nvec3 lightVectorW;\nfloat attenuation=1.0;\nif (lightData.w == 0.)\n{\nvec3 direction=lightData.xyz-vPositionW;\nattenuation=max(0.,1.0-length(direction)/range);\nlightVectorW=normalize(direction);\n}\nelse\n{\nlightVectorW=normalize(-lightData.xyz);\n}\n\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightVectorW);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {\nlightingInfo result;\nvec3 direction=lightData.xyz-vPositionW;\nvec3 lightVectorW=normalize(direction);\nfloat attenuation=max(0.,1.0-length(direction)/range);\n\nfloat cosAngle=max(0.,dot(lightDirection.xyz,-lightVectorW));\nif (cosAngle>=lightDirection.w)\n{\ncosAngle=max(0.,pow(cosAngle,lightData.w));\nattenuation*=cosAngle;\n\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightVectorW);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;\n}\nresult.diffuse=vec3(0.);\n#ifdef SPECULARTERM\nresult.specular=vec3(0.);\n#endif\n#ifdef NDOTL\nresult.ndl=0.;\n#endif\nreturn result;\n}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) {\nlightingInfo result;\n\nfloat ndl=dot(vNormal,lightData.xyz)*0.5+0.5;\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=mix(groundColor,diffuseColor,ndl);\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightData.xyz);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor;\n#endif\nreturn result;\n}\n",lightUboDeclaration:"#ifdef LIGHT{X}\nuniform Light{X}\n{\nvec4 vLightData;\nvec4 vLightDiffuse;\nvec3 vLightSpecular;\n#ifdef SPOTLIGHT{X}\nvec4 vLightDirection;\n#endif\n#ifdef HEMILIGHT{X}\nvec3 vLightGround;\n#endif\nvec4 shadowsInfo;\nvec2 depthValues;\n} light{X};\n#ifdef SHADOW{X}\n#if defined(SHADOWCUBE{X})\nuniform samplerCube shadowSampler{X};\n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\nuniform sampler2D shadowSampler{X};\nuniform mat4 lightMatrix{X};\n#endif\n#endif\n#endif",defaultVertexDeclaration:"\nuniform mat4 viewProjection;\nuniform mat4 view;\n#ifdef DIFFUSE\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform mat4 ambientMatrix;\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\nuniform mat4 lightmapMatrix;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\nuniform mat4 specularMatrix;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform mat4 bumpMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n",defaultFragmentDeclaration:"uniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nuniform vec3 vEmissiveColor;\n\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY \nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\n#ifndef REFRACTIONMAP_3D\nuniform mat4 refractionMatrix;\n#endif\n#ifdef REFRACTIONFRESNEL\nuniform vec4 refractionLeftColor;\nuniform vec4 refractionRightColor;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\n#endif\n#ifdef DIFFUSEFRESNEL\nuniform vec4 diffuseLeftColor;\nuniform vec4 diffuseRightColor;\n#endif\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;\nuniform vec4 emissiveRightColor;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#ifdef REFLECTIONMAP_SKYBOX\n#else\n#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION)\nuniform mat4 reflectionMatrix;\n#endif\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n#endif",defaultUboDeclaration:"layout(std140,column_major) uniform;\nuniform Material\n{\nvec4 diffuseLeftColor;\nvec4 diffuseRightColor;\nvec4 opacityParts;\nvec4 reflectionLeftColor;\nvec4 reflectionRightColor;\nvec4 refractionLeftColor;\nvec4 refractionRightColor;\nvec4 emissiveLeftColor; \nvec4 emissiveRightColor;\nvec2 vDiffuseInfos;\nvec2 vAmbientInfos;\nvec2 vOpacityInfos;\nvec2 vReflectionInfos;\nvec2 vEmissiveInfos;\nvec2 vLightmapInfos;\nvec2 vSpecularInfos;\nvec3 vBumpInfos;\nmat4 diffuseMatrix;\nmat4 ambientMatrix;\nmat4 opacityMatrix;\nmat4 reflectionMatrix;\nmat4 emissiveMatrix;\nmat4 lightmapMatrix;\nmat4 specularMatrix;\nmat4 bumpMatrix; \nvec4 vTangentSpaceParams;\nmat4 refractionMatrix;\nvec4 vRefractionInfos;\nvec4 vSpecularColor;\nvec3 vEmissiveColor;\nvec4 vDiffuseColor;\nfloat pointSize; \n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};",shadowsFragmentFunctions:"#ifdef SHADOWS\n#ifndef SHADOWFLOAT\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}\n#endif\nfloat computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x;\n#endif\nif (depth>shadow)\n{\nreturn darkness;\n}\nreturn 1.0;\n}\nfloat computeShadowWithPCFCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\nfloat visibility=1.;\nvec3 poissonDisk[4];\npoissonDisk[0]=vec3(-1.0,1.0,-1.0);\npoissonDisk[1]=vec3(1.0,-1.0,-1.0);\npoissonDisk[2]=vec3(-1.0,-1.0,-1.0);\npoissonDisk[3]=vec3(1.0,-1.0,1.0);\n\n#ifndef SHADOWFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadow=texture2D(shadowSampler,uv).x;\n#endif\nif (shadowPixelDepth>shadow)\n{\nreturn computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff);\n}\nreturn 1.;\n}\nfloat computeShadowWithPCF(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\nfloat visibility=1.;\nvec2 poissonDisk[4];\npoissonDisk[0]=vec2(-0.94201624,-0.39906216);\npoissonDisk[1]=vec2(0.94558609,-0.76890725);\npoissonDisk[2]=vec2(-0.094184101,-0.92938870);\npoissonDisk[3]=vec2(0.34495938,0.29387760);\n\n#ifndef SHADOWFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0); \n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\n#endif\n",fresnelFunction:"#ifdef FRESNEL\nfloat computeFresnelTerm(vec3 viewDirection,vec3 worldNormal,float bias,float power)\n{\nfloat fresnelTerm=pow(bias+abs(dot(viewDirection,worldNormal)),power);\nreturn clamp(fresnelTerm,0.,1.);\n}\n#endif",reflectionFunction:"vec3 computeReflectionCoords(vec4 worldPos,vec3 worldNormal)\n{\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvec3 direction=normalize(vDirectionW);\nfloat t=clamp(direction.y*-0.5+0.5,0.,1.0);\nfloat s=atan(direction.z,direction.x)*RECIPROCAL_PI2+0.5;\n#ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED\nreturn vec3(1.0-s,t,0);\n#else\nreturn vec3(s,t,0);\n#endif\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR\nvec3 cameraToVertex=normalize(worldPos.xyz-vEyePosition.xyz);\nvec3 r=reflect(cameraToVertex,worldNormal);\nfloat t=clamp(r.y*-0.5+0.5,0.,1.0);\nfloat s=atan(r.z,r.x)*RECIPROCAL_PI2+0.5;\nreturn vec3(s,t,0);\n#endif\n#ifdef REFLECTIONMAP_SPHERICAL\nvec3 viewDir=normalize(vec3(view*worldPos));\nvec3 viewNormal=normalize(vec3(view*vec4(worldNormal,0.0)));\nvec3 r=reflect(viewDir,viewNormal);\nr.z=r.z-1.0;\nfloat m=2.0*length(r);\nreturn vec3(r.x/m+0.5,1.0-r.y/m-0.5,0);\n#endif\n#ifdef REFLECTIONMAP_PLANAR\nvec3 viewDir=worldPos.xyz-vEyePosition.xyz;\nvec3 coords=normalize(reflect(viewDir,worldNormal));\nreturn vec3(reflectionMatrix*vec4(coords,1));\n#endif\n#ifdef REFLECTIONMAP_CUBIC\nvec3 viewDir=worldPos.xyz-vEyePosition.xyz;\nvec3 coords=reflect(viewDir,worldNormal);\n#ifdef INVERTCUBICMAP\ncoords.y=1.0-coords.y;\n#endif\nreturn vec3(reflectionMatrix*vec4(coords,0));\n#endif\n#ifdef REFLECTIONMAP_PROJECTION\nreturn vec3(reflectionMatrix*(view*worldPos));\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nreturn vPositionUVW;\n#endif\n#ifdef REFLECTIONMAP_EXPLICIT\nreturn vec3(0,0,0);\n#endif\n}",imageProcessingDeclaration:"#ifdef EXPOSURE\nuniform float exposureLinear;\n#endif\n#ifdef CONTRAST\nuniform float contrast;\n#endif\n#ifdef VIGNETTE\nuniform vec2 vInverseScreenSize;\nuniform vec4 vignetteSettings1;\nuniform vec4 vignetteSettings2;\n#endif\n#ifdef COLORCURVES\nuniform vec4 vCameraColorCurveNegative;\nuniform vec4 vCameraColorCurveNeutral;\nuniform vec4 vCameraColorCurvePositive;\n#endif\n#ifdef COLORGRADING\n#ifdef COLORGRADING3D\nuniform highp sampler3D txColorTransform;\n#else\nuniform sampler2D txColorTransform;\n#endif\nuniform vec4 colorTransformSettings;\n#endif",imageProcessingFunctions:"#if defined(COLORGRADING) && !defined(COLORGRADING3D)\n\nvec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)\n{\nfloat sliceSize=2.0*sampler3dSetting.x; \n#ifdef SAMPLER3DGREENDEPTH\nfloat sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;\n#else\nfloat sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;\n#endif\nfloat sliceInteger=floor(sliceContinuous);\n\n\nfloat sliceFraction=sliceContinuous-sliceInteger;\n#ifdef SAMPLER3DGREENDEPTH\nvec2 sliceUV=color.rb;\n#else\nvec2 sliceUV=color.rg;\n#endif\nsliceUV.x*=sliceSize;\nsliceUV.x+=sliceInteger*sliceSize;\nsliceUV=clamp(sliceUV,0.,1.);\nvec4 slice0Color=texture2D(colorTransform,sliceUV);\nsliceUV.x+=sliceSize;\nsliceUV=clamp(sliceUV,0.,1.);\nvec4 slice1Color=texture2D(colorTransform,sliceUV);\nvec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);\n#ifdef SAMPLER3DBGRMAP\ncolor.rgb=result.rgb;\n#else\ncolor.rgb=result.bgr;\n#endif\nreturn color;\n}\n#endif\nvec4 applyImageProcessing(vec4 result) {\n#ifdef EXPOSURE\nresult.rgb*=exposureLinear;\n#endif\n#ifdef VIGNETTE\n\nvec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize;\nviewportXY=viewportXY*2.0-1.0;\nvec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0);\nfloat vignetteTerm=dot(vignetteXY1,vignetteXY1);\nfloat vignette=pow(vignetteTerm,vignetteSettings2.w);\n\nvec3 vignetteColor=vignetteSettings2.rgb;\n#ifdef VIGNETTEBLENDMODEMULTIPLY\nvec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);\nresult.rgb*=vignetteColorMultiplier;\n#endif\n#ifdef VIGNETTEBLENDMODEOPAQUE\nresult.rgb=mix(vignetteColor,result.rgb,vignette);\n#endif\n#endif\n#ifdef TONEMAPPING\nconst float tonemappingCalibration=1.590579;\nresult.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);\n#endif\n\nresult.rgb=toGammaSpace(result.rgb);\nresult.rgb=clamp(result.rgb,0.0,1.0);\n#ifdef CONTRAST\n\nvec3 resultHighContrast=applyEaseInOut(result.rgb);\nif (contrast<1.0) {\n\nresult.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);\n} else {\n\nresult.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);\n}\n#endif\n\n#ifdef COLORGRADING\nvec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;\n#ifdef COLORGRADING3D\nvec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb;\n#else\nvec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb;\n#endif\nresult.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);\n#endif\n#ifdef COLORCURVES\n\nfloat luma=getLuminance(result.rgb);\nvec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0));\nvec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;\nresult.rgb*=colorCurve.rgb;\nresult.rgb=mix(vec3(luma),result.rgb,colorCurve.a);\n#endif\nreturn result;\n}",bumpFragmentFunctions:"#ifdef BUMP\n#if BUMPDIRECTUV == 1\n#define vBumpUV vMainUV1\n#elif BUMPDIRECTUV == 2\n#define vBumpUV vMainUV2\n#else\nvarying vec2 vBumpUV;\n#endif\nuniform sampler2D bumpSampler;\n#if defined(TANGENT) && defined(NORMAL) \nvarying mat3 vTBN;\n#endif\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)\n{\n\nuv=gl_FrontFacing ? uv : -uv;\n\nvec3 dp1=dFdx(p);\nvec3 dp2=dFdy(p);\nvec2 duv1=dFdx(uv);\nvec2 duv2=dFdy(uv);\n\nvec3 dp2perp=cross(dp2,normal);\nvec3 dp1perp=cross(normal,dp1);\nvec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;\nvec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;\n\ntangent*=vTangentSpaceParams.x;\nbitangent*=vTangentSpaceParams.y;\n\nfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(bitangent,bitangent)));\nreturn mat3(tangent*invmax,bitangent*invmax,normal);\n}\nvec3 perturbNormal(mat3 cotangentFrame,vec2 uv)\n{\nvec3 map=texture2D(bumpSampler,uv).xyz;\nmap=map*2.0-1.0;\n#ifdef NORMALXYSCALE\nmap=normalize(map*vec3(vBumpInfos.y,vBumpInfos.y,1.0));\n#endif\nreturn normalize(cotangentFrame*map);\n}\n#ifdef PARALLAX\nconst float minSamples=4.;\nconst float maxSamples=15.;\nconst int iMaxSamples=15;\n\nvec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {\nfloat parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;\nparallaxLimit*=parallaxScale;\nvec2 vOffsetDir=normalize(vViewDirCoT.xy);\nvec2 vMaxOffset=vOffsetDir*parallaxLimit;\nfloat numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));\nfloat stepSize=1.0/numSamples;\n\nfloat currRayHeight=1.0;\nvec2 vCurrOffset=vec2(0,0);\nvec2 vLastOffset=vec2(0,0);\nfloat lastSampledHeight=1.0;\nfloat currSampledHeight=1.0;\nfor (int i=0; icurrRayHeight)\n{\nfloat delta1=currSampledHeight-currRayHeight;\nfloat delta2=(currRayHeight+stepSize)-lastSampledHeight;\nfloat ratio=delta1/(delta1+delta2);\nvCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;\n\nbreak;\n}\nelse\n{\ncurrRayHeight-=stepSize;\nvLastOffset=vCurrOffset;\nvCurrOffset+=stepSize*vMaxOffset;\nlastSampledHeight=currSampledHeight;\n}\n}\nreturn vCurrOffset;\n}\nvec2 parallaxOffset(vec3 viewDir,float heightScale)\n{\n\nfloat height=texture2D(bumpSampler,vBumpUV).w;\nvec2 texCoordOffset=heightScale*viewDir.xy*height;\nreturn -texCoordOffset;\n}\n#endif\n#endif",clipPlaneFragmentDeclaration:"#ifdef CLIPPLANE\nvarying float fClipDistance;\n#endif",fogFragmentDeclaration:"#ifdef FOG\n#define FOGMODE_NONE 0.\n#define FOGMODE_EXP 1.\n#define FOGMODE_EXP2 2.\n#define FOGMODE_LINEAR 3.\n#define E 2.71828\nuniform vec4 vFogInfos;\nuniform vec3 vFogColor;\nvarying vec3 vFogDistance;\nfloat CalcFogFactor()\n{\nfloat fogCoeff=1.0;\nfloat fogStart=vFogInfos.y;\nfloat fogEnd=vFogInfos.z;\nfloat fogDensity=vFogInfos.w;\nfloat fogDistance=length(vFogDistance);\nif (FOGMODE_LINEAR == vFogInfos.x)\n{\nfogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart);\n}\nelse if (FOGMODE_EXP == vFogInfos.x)\n{\nfogCoeff=1.0/pow(E,fogDistance*fogDensity);\n}\nelse if (FOGMODE_EXP2 == vFogInfos.x)\n{\nfogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity);\n}\nreturn clamp(fogCoeff,0.0,1.0);\n}\n#endif",clipPlaneFragment:"#ifdef CLIPPLANE\nif (fClipDistance>0.0)\n{\ndiscard;\n}\n#endif",bumpFragment:"vec2 uvOffset=vec2(0.0,0.0);\n#if defined(BUMP) || defined(PARALLAX)\n#ifdef NORMALXYSCALE\nfloat normalScale=1.0;\n#else \nfloat normalScale=vBumpInfos.y;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#else\nmat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,vBumpUV);\n#endif\n#endif\n#ifdef PARALLAX\nmat3 invTBN=transposeMat3(TBN);\n#ifdef PARALLAXOCCLUSION\nuvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z);\n#else\nuvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);\n#endif\n#endif\n#ifdef BUMP\nnormalW=perturbNormal(TBN,vBumpUV+uvOffset);\n#endif",lightFragment:"#ifdef LIGHT{X}\n#if defined(SHADOWONLY) || (defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X}))\n\n#else\n#ifdef PBR\n#ifdef SPOTLIGHT{X}\ninfo=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,NdotL);\n#endif\n#ifdef HEMILIGHT{X}\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,NdotL);\n#endif\n#if defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})\ninfo=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,NdotL);\n#endif\n#else\n#ifdef SPOTLIGHT{X}\ninfo=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#endif\n#ifdef HEMILIGHT{X}\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,glossiness);\n#endif\n#if defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})\ninfo=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#endif\n#endif\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCLOSEESM{X}\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithCloseESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#else\n#ifdef SHADOWESM{X}\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#else \n#ifdef SHADOWPCF{X}\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithPCFCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadowWithPCF(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#else\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#endif\n#endif\n#endif\n#ifdef SHADOWONLY\n#ifndef SHADOWINUSE\n#define SHADOWINUSE\n#endif\nglobalShadow+=shadow;\nshadowLightCount+=1.0;\n#endif\n#else\nshadow=1.;\n#endif\n#ifndef SHADOWONLY\n#ifdef CUSTOMUSERLIGHTING\ndiffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);\n#ifdef SPECULARTERM\nspecularBase+=computeCustomSpecularLighting(info,specularBase,shadow);\n#endif\n#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\ndiffuseBase+=lightmapColor*shadow;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nspecularBase+=info.specular*shadow*lightmapColor;\n#endif\n#endif\n#else\ndiffuseBase+=info.diffuse*shadow;\n#ifdef SPECULARTERM\nspecularBase+=info.specular*shadow;\n#endif\n#endif\n#endif\n#endif",logDepthFragment:"#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif",fogFragment:"#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif", pbrVertexDeclaration:"uniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef ALBEDO\nuniform mat4 albedoMatrix;\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform mat4 ambientMatrix;\nuniform vec3 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\nuniform mat4 lightmapMatrix;\n#endif\n#ifdef REFLECTIVITY \nuniform vec3 vReflectivityInfos;\nuniform mat4 reflectivityMatrix;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform mat4 microSurfaceSamplerMatrix;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform mat4 bumpMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#endif\n",pbrFragmentDeclaration:"uniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\n\nuniform vec4 vLightingIntensity;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\n\n#ifdef ALBEDO\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform vec3 vAmbientInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#ifdef OPACITY \nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef REFLECTIVITY\nuniform vec3 vReflectivityInfos;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\n#endif\n\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#endif",pbrUboDeclaration:"layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec2 vAlbedoInfos;\nuniform vec3 vAmbientInfos;\nuniform vec2 vOpacityInfos;\nuniform vec2 vEmissiveInfos;\nuniform vec2 vLightmapInfos;\nuniform vec3 vReflectivityInfos;\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform vec4 vRefractionInfos;\nuniform vec2 vReflectionInfos;\nuniform vec3 vBumpInfos;\nuniform mat4 albedoMatrix;\nuniform mat4 ambientMatrix;\nuniform mat4 opacityMatrix;\nuniform mat4 emissiveMatrix;\nuniform mat4 lightmapMatrix;\nuniform mat4 reflectivityMatrix;\nuniform mat4 microSurfaceSamplerMatrix;\nuniform mat4 bumpMatrix;\nuniform vec2 vTangentSpaceParams;\nuniform mat4 refractionMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\nuniform vec4 vLightingIntensity;\nuniform vec3 vRefractionMicrosurfaceInfos;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float pointSize;\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};",pbrFunctions:"\n#define RECIPROCAL_PI2 0.15915494\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\n\nconst float kRougnhessToAlphaScale=0.1;\nconst float kRougnhessToAlphaOffset=0.29248125;\nfloat convertRoughnessToAverageSlope(float roughness)\n{\n\nconst float kMinimumVariance=0.0005;\nfloat alphaG=square(roughness)+kMinimumVariance;\nreturn alphaG;\n}\n\nfloat smithVisibilityG1_TrowbridgeReitzGGX(float dot,float alphaG)\n{\nfloat tanSquared=(1.0-dot*dot)/(dot*dot);\nreturn 2.0/(1.0+sqrt(1.0+alphaG*alphaG*tanSquared));\n}\nfloat smithVisibilityG_TrowbridgeReitzGGX_Walter(float NdotL,float NdotV,float alphaG)\n{\nreturn smithVisibilityG1_TrowbridgeReitzGGX(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGX(NdotV,alphaG);\n}\n\n\nfloat normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)\n{\n\n\n\nfloat a2=square(alphaG);\nfloat d=NdotH*NdotH*(a2-1.0)+1.0;\nreturn a2/(PI*d*d);\n}\nvec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow(clamp(1.0-VdotH,0.,1.),5.0);\n}\nvec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow(clamp(1.0-VdotN,0.,1.),5.0);\n}\n\nvec3 computeSpecularTerm(float NdotH,float NdotL,float NdotV,float VdotH,float roughness,vec3 reflectance0,vec3 reflectance90)\n{\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);\nfloat visibility=smithVisibilityG_TrowbridgeReitzGGX_Walter(NdotL,NdotV,alphaG);\nvisibility/=(4.0*NdotL*NdotV); \nfloat specTerm=max(0.,visibility*distribution)*NdotL;\nvec3 fresnel=fresnelSchlickGGX(VdotH,reflectance0,reflectance90);\nreturn fresnel*specTerm;\n}\nfloat computeDiffuseTerm(float NdotL,float NdotV,float VdotH,float roughness)\n{\n\n\nfloat diffuseFresnelNV=pow(clamp(1.0-NdotL,0.000001,1.),5.0);\nfloat diffuseFresnelNL=pow(clamp(1.0-NdotV,0.000001,1.),5.0);\nfloat diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;\nfloat fresnel =\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);\nreturn fresnel*NdotL/PI;\n}\nfloat adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\n\nfloat lightRoughness=lightRadius/lightDistance;\n\nfloat totalRoughness=clamp(lightRoughness+roughness,0.,1.);\nreturn totalRoughness;\n#else\nreturn roughness;\n#endif\n}\nfloat computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)\n{\nconst float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;\nfloat reflectivityLuminance=getLuminance(reflectivityColor);\nfloat reflectivityLuma=sqrt(reflectivityLuminance);\nmicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;\nreturn microSurface;\n}\n\n\nfloat fresnelGrazingReflectance(float reflectance0) {\nfloat reflectance90=clamp(reflectance0*25.0,0.0,1.0);\nreturn reflectance90;\n}\n\n\n#define UNPACK_LOD(x) (1.0-x)*255.0\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {\nfloat microsurfaceAverageSlope=alphaG;\n\n\n\n\n\n\nmicrosurfaceAverageSlope*=sqrt(abs(NdotV));\nfloat microsurfaceAverageSlopeTexels=microsurfaceAverageSlope*cubeMapDimensionPixels;\nfloat lod=log2(microsurfaceAverageSlopeTexels);\nreturn lod;\n}\nfloat environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {\n\n\nfloat temp=NdotVUnclamped+ambientOcclusion;\nreturn clamp(square(temp)-1.0+ambientOcclusion,0.0,1.0);\n}\nfloat environmentHorizonOcclusion(vec3 reflection,vec3 normal) {\n\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflection.z*=-1.0;\n#endif\nfloat temp=clamp( 1.0+1.1*dot(reflection,normal),0.0,1.0);\nreturn square(temp);\n}",harmonicsFunctions:"#ifdef USESPHERICALFROMREFLECTIONMAP\nuniform vec3 vSphericalX;\nuniform vec3 vSphericalY;\nuniform vec3 vSphericalZ;\nuniform vec3 vSphericalXX_ZZ;\nuniform vec3 vSphericalYY_ZZ;\nuniform vec3 vSphericalZZ;\nuniform vec3 vSphericalXY;\nuniform vec3 vSphericalYZ;\nuniform vec3 vSphericalZX;\nvec3 quaternionVectorRotation_ScaledSqrtTwo(vec4 Q,vec3 V){\nvec3 T=cross(Q.xyz,V);\nT+=Q.www*V;\nreturn cross(Q.xyz,T)+V;\n}\nvec3 environmentIrradianceJones(vec3 normal)\n{\n\n\n\n\n\n\n\n\n\nfloat Nx=normal.x;\nfloat Ny=normal.y;\nfloat Nz=normal.z;\nvec3 C1=vSphericalZZ.rgb;\nvec3 Cx=vSphericalX.rgb;\nvec3 Cy=vSphericalY.rgb;\nvec3 Cz=vSphericalZ.rgb;\nvec3 Cxx_zz=vSphericalXX_ZZ.rgb;\nvec3 Cyy_zz=vSphericalYY_ZZ.rgb;\nvec3 Cxy=vSphericalXY.rgb;\nvec3 Cyz=vSphericalYZ.rgb;\nvec3 Czx=vSphericalZX.rgb;\nvec3 a1=Cyy_zz*Ny+Cy;\nvec3 a2=Cyz*Nz+a1;\nvec3 b1=Czx*Nz+Cx;\nvec3 b2=Cxy*Ny+b1;\nvec3 b3=Cxx_zz*Nx+b2;\nvec3 t1=Cz*Nz+C1;\nvec3 t2=a2*Ny+t1;\nvec3 t3=b3*Nx+t2;\nreturn t3;\n}\n#endif",pbrLightFunctions:"\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n};\nfloat computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range)\n{ \n#ifdef USEPHYSICALLIGHTFALLOFF\nfloat lightDistanceFalloff=1.0/((lightDistanceSquared+0.001));\n#else\nfloat lightDistanceFalloff=max(0.,1.0-length(lightOffset)/range);\n#endif\nreturn lightDistanceFalloff;\n}\nfloat computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent)\n{\nfloat falloff=0.0;\n#ifdef USEPHYSICALLIGHTFALLOFF\nconst float kMinusLog2ConeAngleIntensityRatio=6.64385618977; \n\n\n\n\n\nfloat concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);\n\n\nvec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);\nfalloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));\n#else\nfloat cosAngle=max(0.000000000000001,dot(-lightDirection,directionToLightCenterW));\nif (cosAngle>=cosHalfAngle)\n{\nfalloff=max(0.,pow(cosAngle,exponent));\n}\n#endif\nreturn falloff;\n}\nlightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float rangeRadius,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,out float NdotL) {\nlightingInfo result;\nvec3 lightDirection;\nfloat attenuation=1.0;\nfloat lightDistance;\n\nif (lightData.w == 0.)\n{\nvec3 lightOffset=lightData.xyz-vPositionW;\nfloat lightDistanceSquared=dot(lightOffset,lightOffset);\nattenuation=computeDistanceLightFalloff(lightOffset,lightDistanceSquared,rangeRadius);\nlightDistance=sqrt(lightDistanceSquared);\nlightDirection=normalize(lightOffset);\n}\n\nelse\n{\nlightDistance=length(-lightData.xyz);\nlightDirection=normalize(-lightData.xyz);\n}\n\nroughness=adjustRoughnessFromLightProperties(roughness,rangeRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW+lightDirection);\nNdotL=clamp(dot(vNormal,lightDirection),0.00000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90);\nresult.specular=specTerm*diffuseColor*attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float rangeRadius,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,out float NdotL) {\nlightingInfo result;\nvec3 lightOffset=lightData.xyz-vPositionW;\nvec3 directionToLightCenterW=normalize(lightOffset);\n\nfloat lightDistanceSquared=dot(lightOffset,lightOffset);\nfloat attenuation=computeDistanceLightFalloff(lightOffset,lightDistanceSquared,rangeRadius);\n\nfloat directionalAttenuation=computeDirectionalLightFalloff(lightDirection.xyz,directionToLightCenterW,lightDirection.w,lightData.w);\nattenuation*=directionalAttenuation;\n\nfloat lightDistance=sqrt(lightDistanceSquared);\nroughness=adjustRoughnessFromLightProperties(roughness,rangeRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW+directionToLightCenterW);\nNdotL=clamp(dot(vNormal,directionToLightCenterW),0.000000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90);\nresult.specular=specTerm*diffuseColor*attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,out float NdotL) {\nlightingInfo result;\n\n\n\nNdotL=dot(vNormal,lightData.xyz)*0.5+0.5;\nresult.diffuse=mix(groundColor,diffuseColor,NdotL);\n#ifdef SPECULARTERM\n\nvec3 lightVectorW=normalize(lightData.xyz);\nvec3 H=normalize(viewDirectionW+lightVectorW);\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nNdotL=clamp(NdotL,0.000000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90);\nresult.specular=specTerm*diffuseColor;\n#endif\nreturn result;\n}",mrtFragmentDeclaration:"#if __VERSION__>=200\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n",bones300Declaration:"#if NUM_BONE_INFLUENCERS>0\nuniform mat4 mBones[BonesPerMesh];\nin vec4 matricesIndices;\nin vec4 matricesWeights;\n#if NUM_BONE_INFLUENCERS>4\nin vec4 matricesIndicesExtra;\nin vec4 matricesWeightsExtra;\n#endif\n#endif",instances300Declaration:"#ifdef INSTANCES\nin vec4 world0;\nin vec4 world1;\nin vec4 world2;\nin vec4 world3;\n#else\nuniform mat4 world;\n#endif",kernelBlurFragment:"#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCoord{X}))*KERNEL_WEIGHT{X};\n#else\nblend+=texture2D(textureSampler,sampleCoord{X})*KERNEL_WEIGHT{X};\n#endif",kernelBlurFragment2:"#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X}))*KERNEL_DEP_WEIGHT{X};\n#else\nblend+=texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X})*KERNEL_DEP_WEIGHT{X};\n#endif",kernelBlurVaryingDeclaration:"varying vec2 sampleCoord{X};",kernelBlurVertex:"sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};",backgroundVertexDeclaration:"uniform mat4 view;\nuniform mat4 viewProjection;\nuniform float shadowLevel;\n#ifdef DIFFUSE\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif",backgroundFragmentDeclaration:" uniform vec4 vPrimaryColor;\nuniform vec4 vSecondaryColor;\nuniform vec4 vTertiaryColor;\nuniform float shadowLevel;\nuniform float alpha;\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#endif\n#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)\nuniform vec3 vBackgroundCenter;\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 vReflectionControl;\n#endif",backgroundUboDeclaration:"layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec4 vPrimaryColor;\nuniform vec4 vSecondaryColor;\nuniform vec4 vTertiaryColor;\nuniform vec2 vDiffuseInfos;\nuniform vec2 vReflectionInfos;\nuniform mat4 diffuseMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform float pointSize;\nuniform float shadowLevel;\nuniform float alpha;\n#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)\nuniform vec3 vBackgroundCenter;\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 vReflectionControl;\n#endif\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};"},(function(e,t){var i=t();if(!e||!e.BABYLON){("undefined"!=typeof global?global:"undefined"!=typeof window?window:this).BABYLON=i,"object"==typeof exports&&"object"==typeof module?module.exports=i:"function"==typeof define&&define.amd?define(["BABYLON"],t):"object"==typeof exports?exports.BABYLON=i:e.BABYLON=i}})(this,(function(){return BABYLON}));